Difference between Checked and Unchecked
Exception
Checked
Exception
|
Unchecked
Exception
|
Checked
Exception is required to be handled by compile time using try-catch block or
else method should use throws keyword.
|
Unchecked
Exceptions are not required to be handled in the program or to mention them
in throws clause.
|
Super
class of all checked exceptions is Exception.
|
Super
class of all unchecked exceptions RuntimeException.
|
CheckedException
represent scenario with higher failure rate.
Example: FileNotFoundException in reading a file that is not
present.
|
Unchecked
exceptions are mostly caused by poor programming.
Example: NullPointerException when invoking a method on an
object reference without making sure that it’s not null.
|
No comments:
Post a Comment