6.1. Single Implementation Inheritance

One of the fundamental mechanisms for code reuse in OOP, is inheritance. It allows new classes to be derived from an existing class. The new class (a.k.a. subclass, subtype, derived class, child class) can inherit members from the old class (a.k.a. superclass, supertype, base class, parent class). The subclass can add new behavior and properties, and under certain circumstances, modify its inherited behavior.

In Java, implementation inheritance is achieved by extending classes (i.e., adding new fields and methods) and modifying inherited members (see Section 6.2, p. 233). Inheritance of members is closely tied to their declared accessibility. If a superclass member is accessible by its simple name in the ...

Get Programmer's Guide to Java™ Certification, A: A Comprehensive Primer, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.