I am confused regarding a concept in multiple inheritance. I have three classes A, B and C.
Class A {
// ...
}
Class B extends A {
// ...
}
Class C extends B {
// ...
}
I know this is a bad practice of multiple inheritance and I also read java allows multiple inheritance through interfaces. But I am not getting any error in the above code. Please can anyone explain me with a clear example without using interface. Thanks!!
This is not multi-inheritance. Each class has exactly one direct super class. If your example was considered multi-inheritance, you wouldn't be able to use the extends
keyword at all, since each class already extends by default the Object
class.
Multi-inheritence would be
class C extends A,B {}
And that's illegal in Java.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments