|
What is the parent class of the class Sentra? A good answer might be:Nissan. |
Relative TermsThe terms "parent class" and "child class" are not absolute. Any class may be the parent class for a child class derived from it. Just as with human relationships, an individual is a child to some relatives and a parent to others. In Java, the syntax for deriving a child class from a parent class is:
You have already seen this in creating applets:
Many of the characteristics of the applets you have written were inherited from the base class Applet. The base class has code to handle all the details of interfacing with the web browsers, with setting up graphics, and other things. You get to use all that automatically by inheritance. All you need to do is add the additional characteristics you want. |
QUESTION 6:[Thought question:] Can you use one of your own classes (not a predefined class like Applet) as a parent class? Click Here after you have answered the question |