CHECKED – UNCHECKED EXCEPTIONS

Checked exceptions are checked at compile-time. It means if a method is throwing a checked exception then it should handle the exception using try-catch block or it should declare the exception using throws keyword, otherwise the program will give a compilation error.(for example, I/O errors)

FileNotFoundException is a checked exception in Java

Unchecked exceptions are not checked at compile time but occurred during runtime. Most of the times these exception occurs due to the bad data provided by user during the user-program interaction. It is up to the programmer to judge the conditions in advance, that can cause such exceptions and handle them appropriately

All Unchecked exceptions are direct sub classes of RuntimeException class.

Example of unchecked exceptions are : ArithmeticException, ArrayStoreException, ClassCastException

This entry was posted in Basic. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *