
Figure 10.2
The RollABall Class
Hierarchy
Object
Component
Container
Panel
Applet
JApplet
RollABall
656 CHAPTER 10 Object-Oriented Programming,Part 3: Inheritance,Polymorphism,and Interfaces
Let’s look at an example of inheritance that we’ve already used. We’ve used
the extends keyword whenever we wrote an applet. For example, we defined
our rolling ball applet in Chapter 6 as:
public class RollABall extends JApplet
This means that the RollABall class inherits from the JApplet class.
Because our RollABall class extends JApplet, it inherits more than 275 meth-
ods and more than 15 fields. That’s because the JApplet class is a subclass of
Applet, which is a subclass ...