0

Why multiple inheritance is not possible in java

inheritance means getting variables and methods from super class to sub class

23rd Jun 2017, 9:19 AM
medikonda nagasekhar reddy
medikonda nagasekhar reddy - avatar
4 Answers
+ 3
Implement it is complicate, for example: "diamond problem": https://en.wikipedia.org/wiki/Multiple_inheritance
23rd Jun 2017, 9:44 AM
BĂ ng Tứ Cường
BĂ ng Tứ Cường - avatar
0
see this example class A//class A is sub class for test class { int i=10; void m1 () { --x implementation -- } class B // class B is also sub class for test class { int i=20; void m1 () { --y implementation -- } } class test // super class for A,B { while accessing i from class A , B and m1 () method the Compiler with get confusion which variable has to to so to overcome that come problem multiple inheritance is not possible in java }
23rd Jun 2017, 1:51 PM
medikonda nagasekhar reddy
medikonda nagasekhar reddy - avatar
0
Because multiple inheritance ambiguity some scenario in Java. But as a solution you can use interface.
24th Jun 2017, 5:00 PM
Chathuranga Adikari
Chathuranga Adikari - avatar