April 2014
Intermediate to advanced
242 pages
3h 21m
English
An exception is an anomalous condition that alters or interrupts the flow of execution. Java provides built-in exception handling to deal with such conditions. Exception handling should not be part of normal program flow.
As shown in Figure 7-1, all exceptions and errors inherit from the class Throwable, which inherits from the class Object.

Exceptions and errors fall into three categories: checked exceptions, unchecked exceptions, and errors.
throws clause. This must continue all the way up the calling stack until the exception is handled.
catch block.
Exception, and all classes that are subtypes of Exception, except for RuntimeException and the subtypes of RuntimeException.
The following is an example of a method that throws a checked exception:
// Method declaration that throws// an IOExceptionvoidreadFile(Stringfilename)throwsIOException{...}
Read now
Unlock full access