Java Reference
In-Depth Information
At the top of the diagram is the
Object
class. It is the ultimate superclass. If a class is created and no superclass is
specified,
Object
is automatically defined as the superclass. Because we never defined a superclass for Employee and
EmployeeApp, both were defined as subclasses of
Object
.
The online Java documentation shows the class hierarchy. For instance, at the top of the
Frame
page (Figure
3-9
)
notice that the superclasses are listed (first arrow) and match Figure
3-8
. The second arrow points to any
Frame
subclasses. In this case, there is only oneāthe Swing component
JFrame
(which is
not
shown in Figure
3-8
).
Figure 3-9.
In addition, the online documentation shows all methods inherited from the superclasses (this information
follows the class method listing, see Figure
3-10
). Notice that the setBounds method is inherited from the Window
class. (If you scroll back to the
Frame
method list, you will see that there is no entry for setBounds. This list only
includes those methods explicitly defined in the
Frame
class.) As a matter of fact, every subclass of the
Window
class
inherits this method. Can you feel the power of inheritance yet?