Wednesday, February 3, 2016

What are checked and unchecked exceptions?

1) Checked Exception is required to be handled by 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 Unchecked Exception are mostly programming mistakes.

Example of checked Exception 

IOException
DataAccessException
ClassNotFoundException
InvocationTargetException 

Example of unchecked Exception

NullPointerException
ArrayIndexOutOfBound
IllegalArgumentException
IllegalStateException

No comments: