importance of throws keyword in java

Solutions on MaxInterview for importance of throws keyword in java by the best coders in the world

showing results for - "importance of throws keyword in java"
Everly
14 Jan 2019
1Throws statement is used at the end of method signature to indicate that 
2an exception of a given type may be thrown from the method.
3The main purpose of throws keyword is to delegate responsibility of 
4exception handling to the caller methods, in the case of checked exception.
5In the case of unchecked exceptions, it is not required to use throws keyword.
6We can use throws keyword only for throwable types otherwise compile time error 
7saying incompatible types.
8An error is unchecked, it is not required to handle by try catch or by throws.
9  
10  Syntax : Class Test{
11Public static void main(String args[]) throws IE{
12}}
13
14The method should throw only checked exceptions and subclasses 
15of checked exceptions. It is not recommended to specify exception 
16superclasses in the throws class when the actual exceptions thrown in 
17the method are instances of their subclass.