Newsletter sign-up
View all newsletters

Enterprise Java Newsletter
Stay up to date on the latest tutorials and Java community news posted on JavaWorld

Why not multiple inheritance?

Find out why Java's creators prohibited multiple inheritance

  • Digg
  • Reddit
  • SlashDot
  • Stumble
  • del.icio.us
  • Technorati
  • dzone

July 19, 2002

Q Why doesn't the Java language support multiple inheritance?

A Whenever you find yourself asking why Java has or does not have some feature, consider the design goals behind the Java language. With that in mind, I started my search by skimming through "The Java Language Environment" by James Gosling and Henry McGilton (Sun Microsystems), a white paper published in May 1996 that explains some of the reasoning behind Java's design.

As the white paper states, the Java design team strove to make Java:

  • Simple, object oriented, and familiar
  • Robust and secure
  • Architecture neutral and portable
  • High performance
  • Interpreted, threaded, and dynamic


The reasons for omitting multiple inheritance from the Java language mostly stem from the "simple, object oriented, and familiar" goal. As a simple language, Java's creators wanted a language that most developers could grasp without extensive training. To that end, they worked to make the language as similar to C++ as possible (familiar) without carrying over C++'s unnecessary complexity (simple).

In the designers' opinion, multiple inheritance causes more problems and confusion than it solves. So they cut multiple inheritance from the language (just as they cut operator overloading). The designers' extensive C++ experience taught them that multiple inheritance just wasn't worth the headache.

Note: For a discussion of the diamond problem, a classic multiple inheritance challenge, read Bill Venners's "Designing with Interfaces" (JavaWorld, December 1998) and Tony Sintes's "Java Diamonds Are Forever" (JavaWorld, March 2001).


Instead, Java's designers chose to allow multiple interface inheritance through the use of interfaces, an idea borrowed from Objective C's protocols. Multiple interface inheritance allows an object to inherit many different method signatures with the caveat that the inheriting object must implement those inherited methods.

Multiple interface inheritance still allows an object to inherit methods and to behave polymorphically on those methods. The inheriting object just doesn't get an implementation free ride. For an excellent discussion of interface inheritance, read Wm. Paul Rogers's "Reveal the Magic Behind Subtype Polymorphism" (JavaWorld, April 2001).

About the author

Tony Sintes is an independent consultant and founder of First Class Consulting, a consulting firm that specializes in bridging disparate enterprise systems and training. Outside of First Class Consulting, Tony is an active freelance writer, as well as author of Sams Teach Yourself Object-Oriented Programming in 21 Days (Sams, 2001; ISBN: 0672321092).
  • Digg
  • Reddit
  • SlashDot
  • Stumble
  • del.icio.us
  • Technorati
  • dzone
Comments (8)
Login
Forgot your account info?

Not ClearBy Anonymous on February 20, 2010, 2:18 amthe answere could have ben more elaborative, as in general disadvantage of multiple inheritance in any technology. C++ provided multiple inheritance but Java...

Reply | Read entire comment

Multiple inheritance is useful, but it depends how a language deBy Anonymous on February 12, 2010, 4:57 pmMultiple inheritance is useful, but it depends how a language defines it. For example the Eiffel language defines multiple inheritance quite well.

Reply | Read entire comment

java inheritanceBy Anonymous on December 18, 2009, 3:03 amno.there is no question abt multiple inheritance in java.inheritence means reuse the functionality of super class in its subclasses.in interface using only method...

Reply | Read entire comment

really nice one. keep it up :)By Anonymous on December 13, 2009, 12:14 pmreally nice one. keep it up :)

Reply | Read entire comment

Unsatisfactory By Anonymous on October 7, 2009, 12:42 pmGive precise answer

Reply | Read entire comment

View all comments

Add comment
Anonymous comments subject to approval. Register here for member benefits.
Have a JavaWorld account? Log in here. Register now for a free account.
Resources