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

Why does Java not support multiple inheritance yet Python does?

Doesn't the diamond problem also happen in python?

3rd Apr 2018, 5:24 PM
God
God - avatar
1 Answer
+ 2
Java (and C#) don't support multiple inheritance because in normal life you shouldn't need it. The thing you do regularly need is implementing multiple interfaces, and on top of that sometimes inheriting from another class. C# and Java support this using a special interface keyword. Python and C++ have in common that they lack a special keyword for interface, so the only way to use interfaces is by inheriting from an abstract class. As you might need to implement multiple interfaces you therefor need multiple inheritance. While your compiler treats implementing an interface and inheritance in the same way, conceptually they are different. Again: you shouldn't need multiple inheritance (real inheritance)!
3rd Apr 2018, 8:31 PM
Freddy