0

Why Java doesn't support multiple inheritance though all java method are virtual by default? Why diamond problem can arise in Java?

Blacktempel
  • 3,935
  • 3
  • 29
  • 53
amritoit
  • 41
  • 9

4 Answers4

5

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.

rusty_turkey
  • 320
  • 1
  • 3
  • 14
2

Diamond problem cannot arise in Java just because it's no possibility of a multiple inheritance.

Eel Lee
  • 3,513
  • 2
  • 31
  • 49
0

I think it's a sun's arbitrary decision to limit development errors resulting of multiple inheritance programming and romove complexity

flow
  • 4,828
  • 6
  • 26
  • 41
0

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.

Sai prateek
  • 11,842
  • 9
  • 51
  • 66