Exception Hierarchy - rahul00773/JavaConcepts GitHub Wiki

Throwable class access root for java Exception Hierarchy.

The throwable class defines two child classes.

  1. Exception
  2. Error

Exception: Most of the time exceptions are caused by our program and these are recoverable. For example, if our program is to read data from a remote file locating in London. At the run time if remote file is not available then we will get run time exception saying File not found exception. If the file not found exception occurs we can provide local files and continue the rest of the program normally.

try{

"Read data from remote file locating at London" }

catch(FileNotFoundException e){

"use a local file and continue rest of the program normally" }

Error:

Most of the times error are not caused by our program and these are due to lack of system resources. Errors are non-recoverable. For example: If outOfMemoryError occurs being a programmer we can't to anything and the program will be terminated abnormally. SystemAdmin or server admin is responsible to increase heap memory.

                                                  Exception
RunTimeException IOException ServletException RemoteException IntereptedException
AEException EOFException
NullPointerException FileNotFoundException
ClassCastException IntereptedException
IndexOutOfBoundException
--ArrayOutOfBoundException.
--StringIOOException
IllegalArgumentException
--NumberFormatException
                                                   Error:

VMError - StackOverFlowError, OutOfMemoryError AssertionError ExceptionInInitialierError