7.8. Inheritance

Inheritance is the process by which a new class is built on top of a previously written class without the existing class's functionality needing to be rewritten. The extends keyword is used to indicate that one class inherits from another. The original class is usually referred to as the parent class or superclass (called base class in C++ lingo). The new class is known as the child class or subclass (called derived class in C++ lingo). The new child class inherits the nonprivate instance variables and methods but not the constructors of the parent class. However, a constructor in a child class can explicitly call the constructor in the parent class by using super on the first line of the new constructor. Here is a simplified ...

Get Core Web Programming, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.