Objects that adhere to the same interface define an object class. An object that is defined as an instance of an existing object class, with no variations, automatically includes all of the data attributes and methods defined for that object class. An object class that adheres to the interface of another class, yet extends it or includes variations, defines a new subclass, or a derived class. In this case, the original (unmodified) class is sometimes called a super class, or a base class with respect to the derived class.
An object that is defined as an instance of a subclass automatically includes (inherits) all of the data attributes and methods defined for the base class, plus all the extensions and variations defined by the subclass.
The base class/subclass relationship can be nested to any degree, producing a tree-like structure in which the following events occur:
- The data attributes and methods of one object define the base class.
- Each subclass object inherits the data attributes and methods of the base class, but includes data attributes and the methods that override the inherited data attributes and methods, and add new object functionality.