Java Reference
In-Depth Information
SR 11.6
The output produced is:
a. finally
the end
b. one caught
finally
the end
c. two caught
finally
the end
d. finally
11.4 Exception Propagation
SR 11.7
If an exception is not caught immediately when thrown, it begins to
propagate up through the methods that were called to get to the point
where it was generated. The exception can be caught and handled at any
point during that propagation. If it propagates out of the main method,
the program terminates.
SR 11.8
If the exception generating code was added to the level2 method, just
before the call to the level3 method, then the output would not include
any mention of “Level 3” - this is because the call to level 3 does not
occur since the exception is raised before the call is made.
SR 11.9
There is no change. The exception is still raised in level 3. The new code
in level 2 does not get executed.
11.5 The Exception Class Hierarchy
SR 11.10
A checked exception is an exception that must be either (1) caught
and handled or (2) listed in the throws clause of any method that
may throw or propagate it. This establishes a set of exceptions that
must be formally acknowledged in the program one way or another.
Unchecked exceptions can be ignored completely in the code if desired.
SR 11.11
a. True - It inherits from RunTimeException which inherits from
Exception .
b. True - It inherits from Throwable through RunTimeException
and Exception .
c. False - It inherits from RunTimeException so it is unchecked.
d. True - It does not inherit from RunTimeException .
e. True - See, for example, the OutOfRangeException defined in
this section.
f. False - The ArithmeticException is unchecked.
Search WWH ::




Custom Search