CodesJava

Easy learning with example program codes

what are checked and unchecked exceptions in java?


Checked exceptions:

Checked exceptions are those exceptional conditions that are checked by compiler at the compile time. A checked exception forces you to either use try-catch or throws. All exceptions except Error, RuntimeException, and their subclasses are checked exceptions.

e.g. – IOException, SQLException etc.

Unchecked exceptions:

Unchecked exceptions are those exceptional conditions that are not checked by compiler at the compile time. Unchecked exceptions are checked at runtime. An unchecked exception not forces you to either use try-catch or throws. RuntimeException and their subclasses are unchecked exceptions. This Exception can be avoided by programmer.

e.g. – NullPointerException, ArithmeticException etc.

Java interview questions on exception handling



Copyright © 2018 CodesJava DMCA.com Protection Status SiteMap