Interview Question
Software Engineer / Developersas mentioned in the above example... Java don't have it since it want to avoid ambiguity ( Diamond formation problem ).
Give two fixed class having common variable or implementation. You can achieve multiple inheritance by using composition of one class and inheritance of other.
choice depends on which class has more methods to delegate. that becomes inheritance base class.
Multiple inheritance means subclassing from multiple classes.
- Apal January 31, 2009Java doesn't support it for simplicity.
For example,
Class A
{
int a;
}
Class B
{
int a;
}
now as both the classes have variable a if class C inherits from both of them it makes it unnecessarily complex and you need to determine variable a of which class.
You can implement something similar to multiple inheritance using interface.