|
|
Start of Tutorial > Start of Trail > Start of Lesson |
Search
Feedback Form |
Except for theObjectclass, a class has exactly one direct superclass. A class inherits member variables and methods from all its superclasses, whether direct or indirect. A subclass can override methods that it inherits, or it can hide variables or methods that it inherits.The table in section Overriding and Hiding Methods
shows the effect of declaring a method with the same signature as a method in the superclass.
The
Objectclass is the top of the class hierarchy. All classes are descendants from this class and inherit methods from it. Useful methods inherited fromObjectincludetoString,equals,clone,getClass,wait,notify, andnotifyAll.You can prevent a class from being subclassed by using the
finalkeyword in the class's declaration. Similarly, you can prevent a method from being overridden by subclasses by declaring it as a final method.An abstract class can only be subclassed; it cannot be instantiated. An abstract class can contain abstract methods methods that are declared but not implemented. Subclasses provide the implementations for abstract methods.
|
|
Start of Tutorial > Start of Trail > Start of Lesson |
Search
Feedback Form |
Copyright 1995-2005 Sun Microsystems, Inc. All rights reserved.