Interface and Inheritance

Explain why we go for interface instead of multiple inheritnace?

Questions by kutty85

Showing Answers 1 - 3 of 3 Answers

giridhar49

  • Oct 11th, 2008
 

Suppose we have 3 classes A,B,C. Here C is derived from classes A and B. HERE A and B classes have same method suppose print(). As we know we can call base class methods by creating objects of derived class. Suppose if i call the print() method which is in both A and B classes in this situation complier does not know which method to call.
We go for inheritance because "A CLASS CANT EXTENDS 2 or MORE CLASSES, But it can implement any number of interfaces "Hence in Java multiple inheritance is achieved by extending a class and implementing interface (nothing but abstract class).

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions