You are on page 1of 2

Chapter 7

1. A child class is derived from a parent class using inheritance. The methods and variables
of the parent class automatically become a part of the child class, according to the rules of
the visibility modifiers used to declare them. 2. Because a new class can be derived from
an existing class, the characteristics of the
parent class can be reused without the error-prone process of copying and modifying code. 3.
Each inheritance should represent an is-a relationship: the child is-a version of the parent. 4.
A child class may use its own definition of a method instead of the definition provided by
its parent. In this, the child overrides the parent’s definition with its own.
5. The super reference can be used to call the parent’s constructor, which cannot be invoked
directly by name. It can also be used to invoke the parent’s version of an overridden
method.
6. All classes in Java are derived, directly or indirectly, from the Object class. Therefore all
public methods of the Object class, such as equals and toString, are available to every
object.
7. An abstract class is a representation of a general idea. Common characteristics and
method signatures can be defined in an abstract class so that they are inherited by its child
classes.
8. A class member is not usable if it is private, meaning that it cannot be referenced by
name in the child class. However, such members can be referenced indirectly.
9. Polymorphism is the ability of a reference variable to refer to different types of objects at
different times. A method invoked through such a reference is bound to different method
definitions at different times, depending on the type of the object referenced.
10. In Java, a reference variable declared using a parent class can be used to refer to an
object of the child class. If both classes contain a method with the same signature, the parent
reference can be polymorphic.
11. When a child class overrides the definition of a parent’s method, two versions of that
methods exist. If a polymorphic reference is used to invoke the method, the version of the
method that is invoked is determined by the type of the object being referred to, not by the
type of the reference variable.
12. An interface name can be used as the type of a reference. This reference variable can
refer to any object of any class that uses that interface. Because all classes use the same
interface, they have methods with common signatures, which can be dynamically bound.
13. An adapter class implements a listener interface, providing empty definitions for all of its
methods. A listener class can be created by extending the adapter class and overriding the
methods of interest.

You might also like