Abstract vs interface
Which should be used and when?
Just saw that if all abstract methods, then it becomes interface.
Still not got any good example that can justify the usage of abstract, interface and which is better.
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Kirtan PatelRank #292 · 8.6K reputationPosted Aug 4, 2009, 9:09 PM EDT
provide body for these methods once they implement it.
Abstract provides both methods with and without body. Adding new methods in abstract class in middle of development life cycle won't break existing sub classes unless these methods are declared as must override. If there are frequent addition of new methods properties and so on. one should use abstract..
Adding new methods to the interface will force users to go through each and
every sub class that implemented that interface and call these methods.
So its always preferred to use abstract over interface because of this limitation.
Whereas on the other hand interface can fill gap of multiple inheritance. One can
implement from more than one interface. Not same with Abstract. One can inherit
from only one abstract class.
Happy Coding :)
Roei BarRank #1,271 · 1.4K reputationPosted Aug 4, 2009, 9:14 PM EDT
Niradhip ChakrabortyRank #429 · 5.8K reputationPosted Aug 4, 2009, 9:24 PM EDT