Easy learning with example program codes

what is the use of throws keyword in java?

throws is used to throw an exception object implicitly. It is used with the method signature. More than one type of exception can be declared with method signature, they should be comma separated.

1.     throws is mainly used to throw checked exception.
2.     If you are calling a method that declares an exception, you must either caught or declare the exception.
3.     We can rethrow the exception.


methodName () throws comma separated list of exceptionClassNames{}


Java interview questions on exception handling

Please follow and like us:

Copyright © 2019 CodesJava Protection Status SiteMap Reference: Java Wiki