Cover Data Structures and Algorithms with Object-Oriented Design Patterns in Java
next up previous contents index

Multiple Inheritance

In Java a class can be derived from only one base class. That is, the following declaration is not allowed:

class C
    extends A, B // Wrong;
{
}
Nevertheless, it is possible for a class to extend a base class and to implement one or more interfaces:
class C
    extends A
    implements D, E
{
}
The derived class c inherits the members of A and it implements all the methods defined in the interfaces D and E.

It is possible to use derivation in the definition of interfaces. And in Java it is possible for an interface to extend more than one base interface:

interface D
    extends E, F
{
}
In this case, the derived interface D comprises all the methods inherited from E and F as well as any new methods declared in the body of D.


next up previous contents index

Bruno Copyright © 1998 by Bruno R. Preiss, P.Eng. All rights reserved.