Why Java doesn't support multiple inheritance though all java method are virtual by default? Why diamond problem can arise in Java?
-
6Only the people at Sun Microsystems can answer this question. – Rohit Jain Oct 25 '13 at 09:15
-
idea of removing multiple inheritance to remove complexity.. – HackerGK Oct 25 '13 at 09:16
-
1The issue (well, *one* of the issues) with multiple inheritance is name conflicts, it has nothing to do with methods being virtual by default. – T.J. Crowder Oct 25 '13 at 09:17
-
As addendum to TJ said: do not confuse virtual _methods_ with C++ virtual _inheritance_. – Adriano Repetti Oct 25 '13 at 09:32
4 Answers
James Gosling (known as the "father" of Java) said:
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.
Reference: http://javapapers.com/core-java/why-multiple-inheritance-is-not-supported-in-java/
So according to him, they simply did not want to add it as they thought it was a bad idea.
P.S. Using multiple interfaces is NOT the same as multiple inheritance.

- 320
- 1
- 3
- 14
Diamond problem cannot arise in Java just because it's no possibility of a multiple inheritance.

- 3,513
- 2
- 31
- 49
I think it's a sun's arbitrary decision to limit development errors resulting of multiple inheritance programming and romove complexity

- 4,828
- 6
- 26
- 41
Because Interface gives flexibility than concrete classes and we have option to implement multiple interface using single class. This is by agreement we are adhering to two blueprints to create a class. Lets see the pretty definition of java :
JAVA: A simple, object oriented, distributed, interpreted, robust, secure,
architecture neutral, portable, high performance, multithreaded,
dynamic language.
Again there is no possibility of Diamond problem in java because it does not support Multiple Inheritance.

- 11,842
- 9
- 51
- 66