Checked and unchecked exceptions

  • Eclipse: Oxygen
  • Java: 1.8

 In Java, there are two types of exceptions checked and unchecked exceptions.

Java makes this division of exceptions depending on the level of importance of the exception. The checked exceptions are handled by the java compiler itself and the unchecked exception are handled by the user (not mandatory) in case of occurrence of such exceptions.

If any code within a method throws a checked exception, then the method must handle the exception or must specify the exception using the keyword throws.

Unchecked exceptions are not checked at compile time. All exceptions are disabled, so the compiler does not force them to handle or specify the exception. This is handled by the user (not mandatory) in case of the occurrence of such exceptions.

App class

Output

at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileReader.<init>(Unknown Source)
at org.studyeasy.App.main(App.java:11)

Contributed by Poonam Tomar


VIEW COURSES

Buy me a coffee!

 

PayTM QR (INDIA)

  • Get video tutorials
  • Project files set
  • Get¬†Certified

Leave a Reply

avatar
  Subscribe  
Notify of
Close Menu