Objectives |
|
In the inheritance hierarchy, classes become more specific and concrete with each new subclass . If you move from a subclass back up to a superclass, the classes become more general and less specific. Class design should ensure that a superclass contains common features of its subclasses. Sometimes a superclass is so abstract that it cannot have any specific instances. Such a class is referred to as an abstract class .
Sometimes it is necessary to derive a subclass from several classes. This capability is known as multiple inheritance . Java, however, does not allow multiple inheritance. A Java class may inherit directly from only one superclass. This restriction is known as single inheritance . If you use the extends keyword to define a subclass, it allows only one parent class. With interfaces, you can obtain the effect of multiple inheritance.
This chapter introduces abstract classes and interfaces, and discusses how to use wrapper classes for primitive data type values.