9.1 Creating Superclasses and Subclasses

Enduring Understanding

When multiple classes contain common attributes and behaviors, programmers create a new class containing the shared attributes and behaviors forming a hierarchy. Modifications made at the highest level of the hierarchy apply to the subclasses.

Learning Objective

Create an inheritance relationship from a subclass to the superclass.

Essential Knowledge

A class hierarchy can be developed by putting common attributes and behaviors of related classes into a single class called a superclass.

Classes that extend a superclass, called subclasses, can draw upon the existing attributes and behaviors of the superclass without repeating these in the code.

Extending a subclass from a superclass creates an “is-a” relationship from the subclass to the superclass.

The keyword extends is used to establish an inheritance relationship between a subclass and a superclass. A class can extend only one superclass.

Last updated

Was this helpful?