Why the multiple inheritance doesn't supported in java? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why the multiple inheritance doesn't supported in java?

C++ , Common lisp and few other languages supports multiple inheritance while java doesn’t support it. It is just to remove ambiguity, because multiple inheritance can cause ambiguity in few scenarios. One of the most common scenario is Diamond problem.

11th Nov 2016, 4:51 PM
Vijay kumar burla
Vijay kumar burla - avatar
1 Answer
+ 1
However it's possible to implement multiple interfaces with "implements" keyword. Commonly you need only properties of a super class but you need many methods who does different stuff, that are in different interfaces. Inherit from a class if you need to declare "how it is" a class (what properties must have). Implement interfaces to declare "what does" that class. For example a Dog is only an Animal (extends) but it can Bark (implements Barkable(???)) and it can walk (Walkable) and so on.
12th Nov 2016, 6:55 AM
Gleb Golov
Gleb Golov - avatar