Subclasses

Subclasses are created by extending classes. They are designated by appending the keyword, extends, to the class designation line followed by the name of the superclass.

The methods of the superclass may be referred to as if they were included within the subclass. If the subclass has a method with the same name as a method in the superclass, the ubclass version will be used instead of the method in the superclass. If the method does not appear in the subclass, the system will first check the subclass but then move up the class hierarchy to check the methods in the superclass to find the designated method. It is imperative that the programmer visualize messages moving up the class hierarchy in designing and testing programs.