Java Reference
In-Depth Information
Constructors complete their execution in order of derivation. Thus, when a Gamma
object is created, the order is Alpha , Beta , Gamma .
6 . A superclass reference can refer to a subclass object. Explain why this is important as
it is related to method overriding.
When an overridden method is called through a superclass reference, it is the type of
the object being referred to that determines which version of the method is called.
7 . What is an abstract class?
An abstract class contains at least one abstract method.
8 . How do you prevent a method from being overridden? How do you prevent a class
from being inherited?
To prevent a method from being overridden, declare it as final . To prevent a class
from being inherited, declare it as final .
9 . Explain how inheritance, method overriding, and abstract classes are used to support
polymorphism.
Inheritance, method overriding, and abstract classes support polymorphism by en-
abling you to create a generalized class structure that can be implemented by a vari-
ety of classes. Thus, the abstract class defines a consistent interface that is shared by
all implementing classes. This embodies the concept of “one interface, multiple
methods.”
10 . What class is a superclass of every other class?
The Object class.
11 . A class that contains at least one abstract method must, itself, be declared abstract.
True or False?
True.
12 . What keyword is used to create a named constant?
final
Search WWH ::




Custom Search