Throwable Hierarchy

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.
go to previous page   go to home page   go to next page        

Answer:

Yes.

Throwable Hierarchy

Object hierarchy

 

Class Exception and class Error both extend Throwable. A Java method can "throw" an object of class Throwable. (We will do this later on in this chapter.) For example, Scanner threw an exception when it tried to convert "rats" into an integer.

Exceptions are different from Errors because programs can be written to recover from Exceptions, but programs can not be written to recover from Errors. The rest of this chapter discusses Exceptions.

Exceptions can be caught by a part of the program that tries to recover from the problem.

QUESTION 3:

Must a program catch Exceptions?