+ 2

Why java does not support multiple inheritance ?

multiple inhertance is not support in java whats the reason behind it

5th Sep 2017, 4:24 PM
Sachin Gangwar
Sachin Gangwar - avatar
2 Answers
+ 2
every class in java inherits object class so to inherit object class their are two paths available and it becomes ambiguity for the compiler to choose the path second reason is that we can not write two super statement inside the sub class constructor to call the constructor of two super classes
5th Sep 2017, 4:27 PM
Sachin Gangwar
Sachin Gangwar - avatar
0
Simply because Java developers thought multiple inheritance was confusing and would make big programs difficult to maintain. One example is the "diamond problem". (https://en.m.wikipedia.org/wiki/Multiple_inheritance#/3). They decided to include interfaces as a substitute to multiple inheritance. However, you can (sort of) make multiple inheritance with Java 8 and "default methods"
5th Sep 2017, 7:31 PM
Daniel de Lizaur