Friday, August 2, 2013

Checked Exception vs UnChecked Exceptions in java

Checked Exceptions: Exceptions which can be checked by the java compiler are checked Exceptions.These exceptions can be foreseen by the programmer/developer  and they'll be taken care by defining suitable exception classes/by declaring them using throws keyword.

Examples of Checked Exceptions:
IOException
SQLException
DataAccessException
ClassNotFoundException
InvocationTargetException



Unchecked Exceptions: Exceptions which  cant be checked by java compiler.Unchecked Exceptions mostly arise due to programming errors like accessing method of a null object, accessing element outside an array bonding or invoking method with illegal arguments.

  Examples of UnChecked Exceptions:
   NullPointerException
   ArrayIndexOutOfBoundsException
   IllegalArgumentException