what is difference between abstract class and interface with real time example(with simple project)
Loading
what is difference between abstract class and interface with real time example(with simple project)
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
Sachin SinghRank #66 · 26.2K reputationPosted Jan 24, 2022, 2:19 AM EST
An interface has only abstract methods (method without body) but an abstract class can have both abstract as well as non abstract methods (methods with body), so it can also support access modifiers (private,internal etc) but interface has by default public methods only.
so, it is a common practice that whenever you have to create contract (force child class to implement and use same naming conventations) we use interface.
Another benefit of interface is to achieve loose coupling between two projects or classes. we use interface instead of concrete objects which also hides the real implementions from caller class.
so, caller doesn't know which implementation out of the given two implementions, _DepartmentBL pointing to, and will be resolved at run time using dependency injection.
Muhammad Imran AnsariRank #326 · 7.6K reputationPosted Jan 24, 2022, 1:19 AM EST