Is Nissan a child of Automobile? Yes.
Is Nissan the parent of Sentra? Yes.
A class may be the parent for a child class and may be a child of another class. Just as with human relationships, a person is a child of some humans and a parent to others. The syntax for deriving a child class from a parent class is:
class childClass extends parentClass
{
// new characteristics of the child class go here
}
You have already seen this in creating applets:
class yourApplet extends Applet
{
// new characteristics of your applet go here
}
The characteristics of applets are
inherited from the base class Applet
.
This base class contains the details of working with
Web browsers, with setting up graphics, and many other things.
You get all that automatically by inheritance.
All you do is add the additional characteristics you want.