The part of object-oriented technology that defines a superclass is the concept of inheritance. Inheritance is the mechanism by which a new class (called a subclass or derived class) is created from an existing class (called a superclass or base class). The superclass establishes a common interface and foundational behavior that the subclass inherits, possibly modifying or extending it
. In detail:
- A superclass is a class from which other classes (subclasses) derive. It provides shared state (variables) and behavior (methods) that subclasses inherit
- The superclass defines the general or abstract characteristics, while subclasses specialize or extend those features
- Inheritance forms a hierarchy where subclasses inherit and reuse code from their superclasses, enabling code reuse and polymorphism
- The superclass-subclass relationship is fundamental to object-oriented programming and is specified in class declarations (e.g., using
extends
in Java)
Thus, inheritance is the core object-oriented technology concept that defines and enables the existence of superclasses. The superclass is essentially the class that is inherited from, providing a base for subclasses to build upon.