Why do we need interfaces when we have abstract classes in java
Joined: May 21, 2006
Please let me know as to why do we need interfaces in the first place. Everything that can be done with interfaces can also be done with abstract classes. It has to do with multiple inheritence, but I'm not too clear about it. Please help.
Joined: May 08, 2007
I can just explain about interface is that when a class implements a interface it actualy signs a contract with it ,that this class is going to implement all the methods in an interface and as you said what is the need for interface when we can use abstract classes instead,but somtimes there is a requirement that a class requires to implement more than one interface or it requires to implement two different sets of methods so it is possible But if a class wants to implement more than one abstract class you must be knowing that multiple inheritence is not possible in java....... i think this can be one reason for your question..............