+ 5
Why JAVA does not support multiple inheritance ?
Plz explain .
7 odpowiedzi
+ 12
HonFu You are are correct that multiple inheritance is a nightmare to maintain due to ambiguity from name collisions in base members, resulting in the "deadly diamond of death" problem.
https://en.m.wikipedia.org/wiki/Multiple_inheritance#The_diamond_problem
+ 11
I'd say it's a design decision to make things less bug-likely.
When you inherit from several classes and for example they have the same method names, from where will the kid inherit, mommy or daddy? Issues like that.
Other languages let you do it and trust you handle things right. That makes some things easier and other things (debugging) potentially harder.
I'm still quite confused myself even by basic OOP, so I'm looking forward to any 'deeper' answer you may still get.
+ 3
It is mainly because to avoid conflicts between methods and variables.
Suppose if you have 2 classes and methods with same name exist in both classes jre has to stop and think what to execute.
To avoid this java does not support multiple inheritance.
+ 3
Genghis, I share that feeling... but what has that got to do with this question?
+ 2
Genghis, I still don't see where's the relation to the question why Java doesn't have multiple inheritance.
0
HonFu ive thought long and hard, and the relevance is I think its because Java actually is an enterprise hardened language. Its a clever one.