Does Interfaces Provide for Multiple Inheritance?

Often interfaces are touted as an alternative to multiple class inheritance. While interfaces may solve similar problems, interface and multiple class inheritance are quite different animals, in particular:
A class inherits only constants from an interface.
A class cannot inherit method implementations from an interface.
The interface hierarchy is independent of the class hierarchy. Classes that implement the same interface may or may not be related through the class hierarchy. This is not true for multiple inheritance.
Yet, Java does allow multiple interface inheritance. That is, an interface can have multiple superinterfaces.

No comments:

Post a Comment

Please Provide your feedback here