Java Reference
In-Depth Information
FIGURE 11-10 An attempt to divide by 0
QUICK REVIEW
1 . An exception is an object of a specific exception class. Java provides extensive
support for exception handling by providing several exception classes. Java
also allows users to create and implement their own exception classes.
2 . The try / catch / finally block is used to handle exceptions within a program.
3 . Statements that may generate an exception are placed in a try block. The try
block also contains statements that should not be executed if an exception occurs.
4 . A try block is followed by zero or more catch blocks.
5 . A catch block specifies the type of exception it can catch and contains an
exception handler.
6 . The last catch block may or may not be followed by a finally block.
7 . The code contained in the finally block always executes, regardless of
whether an exception occurs, except when the program exits early from a
try block by calling the method System.exit .
8 . If a try block is not followed by a catch block, then it must have the
finally block.
9 . When an exception occurs, an object of a specific exception class is created.
10 . A catch block can catch either all exceptions of a specific type or all types
of exceptions.
11 . The heading of a catch block specifies the type of exception it handles.
12 . The class Throwable , which is derived from the class Object , is the
superclass of the class Exception .
13 . The methods getMessage , printStackTrace , and toString of the
class Throwable are public and so are inherited by the subclasses of
the class Throwable .
1
1
 
 
Search WWH ::




Custom Search