ptg7068951
HOUR 10:Creating Your First Object
a , and all the standard classes you can use in your Java pro-
grams are part of a hierarchy.
Understanding a hierarchy is easier if you understand subclasses and
superclasses. Aclass that inherits from another class is called a.
The class that is inherited from is called a.
In the preceding example, the Modemclass is the superclass of the
ErrorCorrectionModemclass.ErrorCorrectionModemis the subclass of
Modem.
A class can have more than one class that inherits from it in the hierarchy—
another subclass of Modemcould be ISDNModembecause ISDN modems have
behavior and attributes that make them different from error-correcting
modems. If there was a subclass of ErrorCorrectionModemsuch as
InternalErrorCorrectionModem, it would inherit from all classes above it
in the hierarchy—both ErrorCorrectionModemandModem. These inheri-
tance relationships are shown in Figure 10.2.
Modem
Error
Correction
Modem
ISDN
Modem
Internal
Error
Correction
Modem
An example of a class hierarchy.
The classes that make up the standard Java language make full use of
inheritance, so understanding it is essential. You learn more about inheri-
tance during Hour 12, “Making the Most of Existing Objects.”