Java Reference
In-Depth Information
CHAPTER
6
Understanding Inheritance
Inheritance is one of the most important benefits of object-oriented program-
ming. It allows a new class to be written that extends an existing class. This
chapter discusses the details of understanding and implementing inheritance,
including the is a relationship, the extends keyword, the Object class, method
overriding, the super keyword, and how inheritance affects constructors.
An Overview of Inheritance
In object-oriented programming (OOP), a new class can be built upon an exist-
ing class with the new class extending the existing class and inheriting its
attributes and behaviors. Extending a class is called inheritance.
The existing class is referred to as the parent class, and the new class is
referred to as the child class .
Other common OOP terms for the parent class are base class and super
class. The child class is often referred to as the derived class or subclass .
These different terms for the parent and child class are used interchange-
ably but have the same meaning.
139
Search WWH ::




Custom Search