Why JAVA does not support multiple inheritance ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5

Why JAVA does not support multiple inheritance ?

Plz explain .

18th Dec 2018, 10:51 AM
Ravindra
Ravindra - avatar
7 Answers
+ 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
18th Dec 2018, 1:41 PM
David Carroll
David Carroll - avatar
+ 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.
18th Dec 2018, 11:15 AM
HonFu
HonFu - avatar
+ 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.
19th Dec 2018, 12:29 PM
Seniru
Seniru - avatar
+ 3
Genghis, I share that feeling... but what has that got to do with this question?
19th Dec 2018, 8:38 PM
HonFu
HonFu - avatar
+ 2
Genghis, I still don't see where's the relation to the question why Java doesn't have multiple inheritance.
19th Dec 2018, 9:06 PM
HonFu
HonFu - avatar
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.
19th Dec 2018, 8:50 PM
Genghis
Genghis - avatar
- 1
HonFu I am python and only python, but the more I learn the more I wish I learned a statically typed language first
19th Dec 2018, 8:29 PM
Genghis
Genghis - avatar