Multiple Inheritance
Home ] Up ] What's The Problem? ] The Solution ] Why Is That Better? ] [ Multiple Inheritance ] What is an Interface? ] Nouns vs. Adjectives ] Interface Inheritance ] Marker Interfaces ]

 

 

Single vs. Multiple Inheritance

Java allows a class to inherit from only a single superclass.  This is called single inheritance.

In contrast, C++ supports both single and multiple class inheritance.  Experience has shown, however, that using multiple inheritance is often problematic;  it is very complex, rife with pitfalls, and is one of the most difficult and non-intuitive features of that language. Using uncontrolled multiple inheritance can be dangerous to your sanity!

However, Java does allow a class to implement many interfaces. 

We say that Java supports:

  • Single implementation inheritance (extend from a superclass)
  • Multiple interface inheritance (implement zero or more interfaces)

As a result, Java avoids the horrible problems of generalized multiple inheritance. 

 

This page was last modified on 02 October, 2007