Subclasses, Superclasses, and Inheritance

When you write your first object-oriented program, you do not have to begin your real-world modeling from scratch. Rexx provides predefined classes and methods. From there you can create additional classes and methods of your own, according to your needs.

Rexx classes are hierarchical. Any subclass (a class below another class in the hierarchy) inherits the methods and variables of one or more superclasses (classes above a class in the hierarchy):

Figure 1-8. Superclass and Subclasses

You can add a class to an existing superclass. For example, you might add the Icon class to the Screen-Object superclass:

Figure 1-9. The Screen-Object Superclass

In this way, the subclass inherits additional methods from the superclass. A class can have more than one superclass, for example, subclass Bitmap might have the superclasses Screen-Object and Art-Object. Acquiring methods and variables from more than one superclass is known as multiple inheritance:

Figure 1-10. Multiple Inheritance