
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is the difference between throw and throws keywords in Java?
The throw keyword is used to raise an exception explicitly.
Example
public class Test { public static void main(String[] args) { throw new NullPointerException(); } }
Exception in thread "main" java.lang.NullPointerException at a6.dateAndTime.Test.main(Test.java:5)
The throws keywords in Java used to postpone the handling of a checked exception.
public class Test { public static void main(String[] args)throws NullPointerException { throw new NullPointerException(); } }