What types of Exceptions exist in Java (and what is the difference)? Name few common Exceptions of each type.

1 answers

In Java there are 2 type of Exceptions, checked and unchecked.

The checked exceptions are checked at compile and they must be either handled in a catch block, or they must be specified in the throws section of the method. The checked exceptions are subclasses of the Exceptions class and some of the most common exceptions of this type are: IOException, SQLException, ClassNotFoundException etc.

The unchecked Exceptions are not checked at compile time and don't have to be handled in a catch block or declared in the throws section of the method. The unchecked Exceptions are subclasses of the RuntimeException and some of the most common exceptions of this type are: IllegalArgumentException, NullPointerException, IllegalStateException.

shilpigupta22 shilpigupta22 [Author] 6 months ago votes 0