Friday, February 4, 2011

Is really multiple inheritance supported by Java ?

Is java really supports multiple inheritance using interfaces ? Because if we implement multiple interfaces in a class then we are inheriting nothing from parent class, because nothing concrete in interface. So can we consider it as inheritance in pure OO term ?
------------
Inheritance is a mechanism to achieve the following:
1. Type inheritance - the derived class IS-A base class
2. Behavior inheritance - the derived class exposes at least the same behavior as the base class. It can exhibit more behavior.
3. State inheritance - the derived class has at least the same state states as the parent

Inheritance using interfaces allows only the first two.

So, in pure OO terminology, java doesnt have multiple inheritance.

Just in case you were wondering about the first sentence, Mixin is another approach at achieving points 2 and 3 leaving out 1.

No comments:

Post a Comment