Reason Of eliminating Multiple Inheritance in Java : Deadly Diamond Of Death

Posted by
JAVA is a programming language and environment that was designed to solve a number of problems in modern programming practice. It started as a part of a larger project to develop advanced software for consumer electronics. These are small reliable portable distributed real-time embedded systems. When we started the project, we intended to use C++, but we encountered a number of problems. Initially these were just compiler technology problems, but as time passed we encountered a set of problems that were best solved by changing the language.
JAVA omits many
rarely used, poorly understood, confusing features of C++ that in our
experience bring more grief than benefit. This primarily consists of
operator overloading (although it does have method overloading),
multiple inheritance, and extensive automatic coercions.

Above statement is said by Dr. James Gosling (Father of java) in his White Paper titled “Java : an Overview” in feb 1995.

Multiple Inheritance had been elimiated because of one important reason Deadly Diamond Of Death.

What is Deadly Diamond Of Death(DDD)?

Lets take an example to understand this. A Super Class A has a method go(), two sub class B and C has extended the Super Class A and both class override the method go(). Now take a class D which extended the both class B and C. Represent the problem by a below diagram:

It looks like a diamond and compiler has no way to find out which go() would the subclass D inherit? Thats why this scenario is called Deadly Diamond Of Death.

This is the reason java does not support Multiple inheritance.

3 comments

  1. Well, I learned programming in Java, but I need to earn practical experience that can help securing a bright career in a long run. Therefore, I have joined several Java forums to get easy solution for my queries.

Leave a Reply