java interview Questions
4.23K subscribers
61 photos
23 files
159 links
java interview questions for beginners
Any promotion for
rajp6133@gmail.com
Download Telegram
Throw And Throws In Java

throw:

throw is used in re-throwing exception process or we can say that it is used to throw an exception object explicitly. It can take at most one argument which will be an exception object. Only unchecked exception can be thrown.
throws:

throws keyword is used to throw an exception object implicitly. The throws keyword is used with the method signature. We can declare more than one type of exceptions with method signature which should be comma separated.
Note:
1.     throws is commonly used to throw checked exception.
2.     If we are calling a method that declares an exception then we must have to either caught or declare the exception.
3.     Exception can be re-thrown.

https://cjavapoint.blogspot.com/?m=1