Inheritance vs Interfaces | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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 ?

28th Jun 2016, 12:04 PM
Thomas Rohart
Thomas Rohart - avatar
1 Answer
+ 4
If you are asking the question just in respect of overriding a method.. then in case of an 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 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..
28th Jun 2016, 6:58 PM
Shraddha -
Shraddha - - avatar