Monthly Archives: April 2022

The Subtype–Supertype Relationship A class defines a reference type, a data type whose objects can be accessed only by references. Therefore, the inheritance hierarchy can be regarded as a type hierarchy, embodying the subtype–supertype relationship between reference types. The subclass– superclass relationship is a special case of the subtype–supertype relationship that is between classes. The subclass–superclass relationship allows single inheritance of type, meaning that the subclass inherits the type of its direct superclass. This is in contrast to a class that implements several interfaces, resulting in multiple inheritance of type—that is, a class inherits the type of all interfaces it implements. In the context of Java, the subtype–supertype relationship implies that the reference value of a subtype object can be assigned to a supertype reference because a subtype object can be substituted for a supertype object. This assignment involves a widening reference conversion, as references are assigned up the inheritance…

Read more

1/1