Java Reference
In-Depth Information
StaticParamsDemo.java
The demonstration of static overloading and
dynamic dispatch shown in Figure 4.45.
BadEqualsDemo.java
Illustrates the consequences of overloading
instead of overriding equals , as shown in
Figure 4.46.
exercises
IN SHORT
4.1
What members of an inherited class can be used in the derived class?
What members become public for users of the derived class?
What is composition?
4.2
Explain polymorphism. Explain dynamic dispatch. When is dynamic
dispatch not used?
4.3
4.4
What is autoboxing and unboxing?
4.5
What is a final method?
4.6
Consider the program to test visibility in Figure 4.48.
a.
Which accesses are illegal?
b.
Make main a method in Base . Which accesses are illegal?
c.
Make main a method in Derived . Which accesses are illegal?
d.
How do these answers change if protected is removed from line 4?
e.
Write a three-parameter constructor for Base . Then write a five-
parameter constructor for Derived .
f.
The class Derived consists of five integers. Which are accessible
to the class Derived ?
g.
A method in the class Derived is passed a Base object. Which of
the Base object members can the Derived class access?
What is the difference between a final class and other classes? Why
are final classes used?
4.7
What is an abstract method? What is an abstract class?
4.8
What is an interface? How does the interface differ from an abstract
class? What members may be in an interface?
4.9
Explain the design of the Java I/O library. Include a class hierarchy
picture for all the classes described in Section 4.5.3.
4.10
How were generic algorithms implemented in Java before Java 5?
How are they implemented in Java 5?
4.11
 
Search WWH ::




Custom Search