Java Reference
In-Depth Information
19. The public members of a class can be accessed anywhere the class is used. The
protected members of the base class can be directly accessed only by the methods
of the derived class.
21. These statements are legal because a reference variable of a superclass type can point
to an object of a subclass. Therefore, the formal parameter st can point to the
objects student1 and student2 .
23. An abstract method is a method that only has the heading with no body. Moreover,
the heading of an abstract method contains the reserved word abstract and ends
with a semicolon.
25.
Java does not support multiple inheritance. That is, a class can only extend the
definition of one class. In other words, a class can be derived from only one existing
class. However, a Java program might contain a variety of GUI components and
thus generate a variety of events such as window events, mouse events, as well as
action events. These events are handled by separate interfaces. Therefore, a program
might need to use more than one interface.
Chapter 11
1. a. True; b. False; c. False; d. True; e. False; f. True; g. True; h. False; i. True; j. False
3. The program will terminate with an error message.
5.
If an exception is thrown in a try block, the remaining statements in that try
block are ignored. The program searches the catch blocks in the order they appear
after the try block, and looks for an appropriate exception handler. If the type of
thrown exception matches the parameter type in one of the catch blocks, the code
of that catch block executes and the remaining catch blocks after this catch
block are ignored. If there is a finally block after the last catch block, the
finally block executes regardless of whether an exception occurs.
7.
a. Leaving try block.
b. Balance must be greater than 1000.00.
c. Balance must be greater than 1000.00.
9.
a. Entering the try block.
Exception: Lower limit violation.
After the catch block
b. Entering the try block.
Exception: / by zero
After the catch block
c. Entering the try block.
Exiting the try block.
After the catch block
d. Entering the try block.
Exception: / by zero
After the catch block
 
 
Search WWH ::




Custom Search