The Power of Inheritance
Without knowing it, you have used inheritance every time you worked with one of the standard Java classes such as String or Math. Java classes are organized into a pyramid-shaped hierarchy of classes in which all classes descend from the Object class.
A class of objects inherits from all superclasses that are above it. To get a working idea of how this operates, you'll look at the JApplet class. This class is a superclass of all Swing applets, Java programs written to run on the World Wide Web. The JApplet class, which is used to create Java 2 applets, is a subclass of Applet.
A partial family tree of JApplet is shown in Figure 12.1. Each of the boxes is a class, and the lines connect a superclass to any subclasses below ...