Everybody knows that in java we can only extend "ONE" class.
But for the sake of understanding:
In such a case we are extending two classes by default.
Why is it allowed if Java doesn't support multiple inheritance ?
That would be a multilevel inheritance. You are mistaking multiple to multilevel.
A->B->C //This is multilevel inheritance which you are talking about
Multiple inheritance is like (which is not possible in java)
A
| |
B C
Java doesn't support multiple inheritance that makes any ambiguous cases to fade away. But careful implementation of implement keyword for implementing does give feel of multiple inheritance
Conclusion:
Class A can extend a class B which extends class C. This is still single inheritance. All the classes form a tree, where the root is the Object class, and each class (except of Object) has exactly one direct super-class (or parent class)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With