Exceptions: When Things Go Wrong
10.3 Java’s Exception Hierarchy
The Exception Class
The java.lang.Exception class itself is very simple, consisting of
just two constructor methods (Fig. 10.5). The Throwable class, from
which Exception is derived, is the root class of Java’s exception and
error hierarchy. It contains definitions for the getMessage() and
printStackTrace() methods, which are two methods that we will use
frequently in our error-handling routines.
SELF-STUDY EXERCISE
EXERCISE 10.2 Which of the following are examples of unchecked exceptions?
a. IOException
b. IndexOutOfBoundsException
c. NullPointerException
d. ClassNotFoundException
e. NumberFormatException