Exception Hierarchy and Types

Exception Hierarchy and Types

Java exception handling is used to handle error conditions in a program systematically by taking the necessary actions. Therefore stated simply, the exception-handling capability of Java makes it possible for us to: All exception types are subclasses of the Java built-in class java.lang.Throwable (which is a subclass of java.lang.Object). Thus, Throwable is at the top of the exception class hierarchy. Immediately below Throwable are two subclasses that partition exceptions into two distinct branches: java.lang.Exception and java.lang.Error. The objects that inherit from the Throwable class include direct descendants (objects that inherit directly from the Throwable class) and indirect descendants (objects that inherit from children or grandchildren of the Throwable class). Figure 6.3 below illustrates the class hierarchy of the Throwable class and its most significant subclasses.