Hi
Differentiate between Unchecked & Checked Exceptions in Java. Please tell me its complete detail
Regards.
Answered By
James20
5 points
N/A
#96088
Differentiate between Unchecked & Checked Exceptions
Â
Unchecked Exceptions:
Â
Exceptions that need not be explicitly declared nor caught in the try-catch block. For e.g. StringIndexOutOfBoundsException thrown by String's charAt() method.
Checked Exceptions:
Â
Exceptions that need to be explicitly declared and caught/handled appropriately when the method is invoked.
Â
Differentiate between Unchecked & Checked Exceptions
The difference is checked exceptions must be explicitly caught or propagated checked exceptions in Java extend the java.lang.Exception class. While as unchecked exceptions do not have to be caught or declared thrownunchecked exceptions are Runtime Exception and any of its subclasses. Class Error and its subclasses also are uncheckedexceptions extend the java.lang.RuntimeException .
Differentiate between Unchecked & Checked Exceptions
Hi petersulliva here is the difference between the two clarified for you below hereÂ
UNCHECKED EXCETIONS:
-
 It represents defect in  program (bugs) or errors- often invalid arguments gets passed to non private methods. To get quote from The Java Programming Language, by Gosling, Arnold "Unchecked runtime exceptions represent conditions that, or  generally speaking, reflects errors in programs logic and can’t be reasonably recovered from run time."
-
are also subclasses of RuntimeException, and are implemented using IllegalArgumentException, NullPointerException.
-
a method is not used to establish a policy for unchecked exceptions occurred by its implementation (and they almost always do not do so)
CHECKED EXCEPTIONS:
-
It represents invalid conditions in areas present outside immediate control of program.
-
are subclasses of exception
-
Checked exception is also a method to establish a policy for all checked exceptions occurred by implementation either pass the checked exception further upwards in the stack  or handle it somehow Â
Â
Â