Inheritance vs Interfaces | Sololearn: Learn to code for FREE!

+1

Inheritance vs Interfaces

what is the best choise between this both concept ? how choise one or other ? When I want redefine a method its possible with the both so what are your advices to use them ?

6/28/2016 12:04:41 PM

Thomas Rohart

1 Answer

New Answer

+4

If you are asking the question just in respect of overriding a method.. then in case of an interface..you just have a contract that we will have all these methods as part of the code of the class that is going to implement the interface.. Interface will not have any functionalities in any of the methods..Interfaces..to be precise have public abstract methods.. Now coming to Inheritance. . you can have a super class with a method already defined with its full fledged functionality.. and if you are inheriting the super class and you are able to access the method in your sub class then.. you have choice to either add more functionalities or override it completely..