Java Reference
In-Depth Information
14
.
The method
getMessage
returns the string containing the detailed message
stored in the exception object.
15
.
The method
toString
(in
class
Exception
) returns the detailed message
stored in the exception object as well as the name of the exception class.
16
.
The
class
Exception
and its subclasses are designed to catch exceptions
that should be caught and processed during program execution, and thus
make a program more robust.
17
.
The
class
Exception
is the superclass of the classes designed to handle
exceptions.
18
.
The
class
Exception
is contained in the package
java.lang
.
19
.
The classes to deal with I/O exceptions, such as the file not found exception,
are contained in the
package
java.io
.
20
.
The
class
InputMismatchException
is contained in the package
java.util
.
21
.
The classes to deal with number format exceptions and arithmetic excep-
tions, such as division by zero, are contained in the
package
java.lang
.
22
.
Generally, exception classes are placed in the package that contains the
methods that throw these exceptions.
23
.
Java's predefined exceptions are divided into two categories—checked
exceptions and unchecked exceptions.
24
.
Any exception that can be recognized by the compiler is called a checked
exception.
25
.
Unchecked exceptions are exceptions that are not recognized by the compiler.
26
.
Typically, a
catch
block does one of the following:
Completely handles the exception.
Partially processes the exception. In this case, the
catch
block either
rethrows the same exception or throws another exception for the
calling environment to handle the exception.
Rethrows the same exception for the calling environment to handle the
exception.
27
.
The general syntax to rethrow an exception caught by a
catch
block is:
throw
exceptionReference;
28
.
The general syntax to throw your own exception object is:
throw new
ExceptionClassName(messageString);
29
.
The method
printStackTrace
is used to determine the order in which
the methods were called and where the exception was handled.
30
.
The exception class that you define extends the
class
Exception
or one
of its subclasses.
31
.
Action events are handled by appropriately implementing the
interface
ActionListener
.
Search WWH ::
Custom Search