Start of Tutorial > Start of Trail > Start of Lesson |
Search
Feedback Form |
Recall from the previous lesson that theextends
clause declares that your class is a subclass of another. You can specify only one superclass for your class (Java does not support multiple class inheritance), and even though you can omit theextends
clause from your class declaration, your class has a superclass. So, every class in Java has one and only one immediate superclass. This statement leads to the question, "Where does it all begin?"As depicted in the following figure, the top-most class, the class from which all other classes are derived, is the
Object
class defined injava.lang
.The Object
class defines and implements behavior that every class in the Java system needs. It is the most general of all classes. Its immediate subclasses, and other classes near top of the hierarchy, implement general behavior; classes near the bottom of the hierarchy provide for more specialized behavior.The next section, Understanding Inheritance, talks about the various issues involved in extending any class, such as which members it inherits, which members it can override or hide, and which it cannot. The section that follows, Being a Descendent of Object, describes what all classes inherit from the
Definition: A subclass is a class that extends another class. A subclass inherits state and behavior from all of its ancestors. The term "superclass" refers to a class's direct ancestor as well as to all of its ascendant classes.Object
class and how these classes implement their inherited functionality.
Start of Tutorial > Start of Trail > Start of Lesson |
Search
Feedback Form |
Copyright 1995-2002 Sun Microsystems, Inc. All rights reserved.