Question: What is the guideline for deciding between a checked and unchecked exception? Answer:
If a client can reasonably be expected to recover from an exception, make it a checked exception.
If a client cannot do anything to recover from the exception, make it an unchecked exception.
These categories are related to each other, and subclasses of the class java.lang.Exception
are categorized as checked exceptions if they are not subclasses of the class java.lang.RuntimeException.
Subclasses of the class java.lang.RuntimeException are categorized as runtime exceptions.
Subclasses of the class java.lang.Error are categorized as errors.
Figure 2.8 illustrates the class hierarchy of these exception categories.