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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access