top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Difference between checked and unchecked exception in Java?

+1 vote
876 views
Difference between checked and unchecked exception in Java?
posted Mar 25, 2014 by Aman

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

3 Answers

+2 votes
 
Best answer

Checked exception is checked by the compiler at compile time. It's mandatory for a method to either handle the checked exception or declare them in their throws clause. These are the ones which are a sub class of Exception but doesn't descend from RuntimeException.

The unchecked exception is the descendant of RuntimeException and not checked by the compiler at compile time.

answer Oct 24, 2016 by Nway Nadar
+2 votes

Checked Exception is checked by compiler and it's handling is enforced by mandating try-catch or try-finally block.Unchecked Exception is not checked by compiler but can be caught using try-catch or try-finally block.

answer Mar 26, 2014 by Pavan P Naik
+1 vote

Checked exceptions are the ones checked during compile time e.g. I/O Exception etc. Unchecked exceptions occur during runtime. e.g. Nullpointerexception or we can say all exception except runtime exception is checked exception.

  1. Checked Exception is required to be handled at compile time while Unchecked Exception doesn't.
  2. Checked Exception is direct sub-Class of Exception while Unchecked Exception are of RuntimeException.
  3. Checked Exception represent scenario with higher failure rate while UnCheckedException are mostly programming mistakes.
answer Aug 26, 2015 by Salil Agrawal
...