+ 5

  Why multiple inheritance is not supported in java?

9th Sep 2017, 7:07 AM
⓱ⓐⓝⓓⓔⓔⓟ
⓱ⓐⓝⓓⓔⓔⓟ - avatar
3 RĂ©ponses
+ 3
if I'm not mistaken, it's possible to do everything that is done with multiple inheritance using the interfaces.
9th Sep 2017, 3:04 PM
Malkon F
Malkon F - avatar
+ 3
Java doesn’t allow multiple inheritance to avoid the ambiguity caused by it. Suppose there are four classes A, B, C and D. Class B extends class A as well as class C extends class A. Class D extends both classes B & C. Now lets assume we have a method in class A and class B & C overrides that method in their own way. Here the problem comes – Because D is extending both B & C so if D wants to use the same method which method would be called (the overridden method of B or the overridden method of C). Ambiguity. That’s the main reason why Java doesn’t support multiple inheritance.
4th Oct 2017, 4:17 PM
Shivam Kumar
Shivam Kumar - avatar
0
I don't know that much about it but I think it is because it could lead to bugs and owerwrites of methods
9th Sep 2017, 8:52 AM
Marcus SĂžndergaard
Marcus SĂžndergaard - avatar