I am pretty new to OOP. We all know that Java does not support multiple inheritance; however, all Java classes inherit from Object
and can also inherit from another class. Can we consider this as multiple inheritance? How does Java handle such a thing?
It's not multiple inheritance it's multi level inheritance. Classes can extend one other class, which can extend one other class, ..., which ultimately extends Object:
A --> B --> C --> Object
Multiple inheritance would be
A ----> B
\
\--> C
This means that when a method or a field is used inside A, it's looked up in A, then in B, then in C, then in Object.
With multiple inheritance, it would have to be looked up in A, then in B and C, and there could be a conflict because the same method or field could exist in both superclasses.
That is not multiple inheritance ....That is multi level inheritance in java
Excepting Object, which has no superclass, every class has one and only one direct superclass (single inheritance). In the absence of any other explicit superclass, every class is implicitly a subclass of Object.
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