The JavaTM Tutorial

| Start of Tutorial > Start of Trail > Start of Lesson | Search Feedback Form

Trail: Learning the Java Language
Lesson: Classes, Interfaces, and Packages

## Managing Inheritance

> Recall from the previous lesson that the `extends` 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 the `extends` 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 in `java.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.

> > 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.

> 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 `Object` class and how these classes implement their inherited functionality.

| Start of Tutorial > Start of Trail > Start of Lesson | Search Feedback Form