Java Reference
In-Depth Information
10.6 Designing for Polymorphism
SR 10.20-SR 10.22 For the questions in this section, reasonable arguments
can be made for using either inheritance or interfaces in
each of the situations described. The point of the questions
is to have students think about choices, consider alternative
approaches, and practice making technical arguments to sup-
port their decisions.
Chapter 11 Exceptions
11.1 Exception Handling
SR 11.1
An exception is an object that defines an unusual or erroneous situation.
An error is similar, except that an error generally represents an unrecov-
erable situation and should not be caught.
SR 11.2
A thrown exception can be handled in one of three ways: it can be
ignored, which will cause a program to terminate; it can be handled
where it occurs using a try statement; or it can be caught and handled
higher in the method calling hierarchy.
11.2 Uncaught Exceptions
SR 11.3 a. False - Exceptions and errors are related but are not always the same
thing.
b. True - Division by zero is invalid, so an exception is thrown.
c. False - An exception must be either handled or thrown.
d. True - If the exception is not handled, the program will terminate
and display a message.
e. True - That is the purpose of the call stack trace.
11.3 The try-catch Statement
SR 11.4
A catch phrase of a try statement defines the code that will handle a
particular type of exception.
SR 11.5
The finally clause of a try statement is executed no matter how the try
block is exited. If no exception is thrown, the finally clause is executed
after the try block is complete. If an exception is thrown, the appropriate
catch clause is executed; then the finally clause is executed.
Search WWH ::




Custom Search