e
Characteristics of Inheritance

- All operations and attributes are inherited. It is not possible to exclude inherited properties in a subclass.
- Additional attributes and operations may be added in a subclass.
- Any class may have an arbitrary number of subclasses.
Since a subclass is a specialization of the superclass, it is possible that the subclass needs a specialized version of the operations of the superclass.
It is possible to redefine or override methods, which are defined "higher up" in the hierarchy.
Some classes are not intended to be instantiated, that is, we do not expect objects to be created from these classes.
Take the class Vehicle for example: we probably don't want to create any Vehicle objects -- the class Vehicle is only used to hold the common properties of all its subclasses. Class Vehicle is then called an abstract class.
Single inheritance: A class may only inherit from one superclass.
This is the most widely used type of inheritance relation.
Multiple inheritance: A class may inherit from more than one superclass.
This is more powerful, but also more complex to use.
Some programming languages, methods and tools only provide support for single inheritance, while others allow the use of multiple inheritance.
previous |
next |
start |
contents |
dictionary |
help |
evaluation
© Ericsson Telecom AB, 1995, Stockholm, Sweden