go to previous page   go to home page   go to next page

Answer:

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.


Extends

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 may have already seen this in creating applets:

class yourApplet extends JApplet
{
  // new characteristics of your applet go here
  
}

The characteristics of applets are inherited from the base class JApplet. This base class contains the details of working with Web browsers by setting up graphics and many other things. You get all that automatically by inheritance. All you do is add the additional characteristics you want.


QUESTION 8:

(Thought question:) Can your class extend more than one parent class?