Fiveable
Fiveable

Superclass

Definition

A superclass, also known as a parent class or base class, is a class that is extended by another class (subclass). It provides common attributes and behaviors that can be inherited by its subclasses.

Analogy

Think of a superclass as a template for creating different types of vehicles. For example, the superclass "Vehicle" could have common features like wheels, engine, and steering. Now, when you create specific types of vehicles like "Car" or "Motorcycle," they inherit these common features from the superclass while adding their own unique characteristics.

Related terms

Subclass: A subclass is a class that extends another class (superclass). It inherits all the attributes and behaviors from its superclass while adding its own additional features.

Inheritance: Inheritance is the mechanism in Java where one class acquires properties (fields and methods) from another class. It allows code reuse and promotes hierarchical organization of classes.

Method Overriding: Method overriding occurs when a subclass provides its own implementation of a method that already exists in its superclass. The overridden method in the subclass replaces the original implementation provided by the superclass.

"Superclass" appears in:

Practice Questions (19)



© 2024 Fiveable Inc. All rights reserved.

AP® and SAT® are trademarks registered by the College Board, which is not affiliated with, and does not endorse this website.


© 2024 Fiveable Inc. All rights reserved.

AP® and SAT® are trademarks registered by the College Board, which is not affiliated with, and does not endorse this website.