When we go for abstract class and interface plz give me ans
thanks in advance
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
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
Saineshwar BageriRank #115 · 19.6K reputationPosted Mar 29, 2015, 8:31 PM EDT
when we want a class that implement all method than that time we should use interface.
Abstract
When we want some method of abstract to be used and some we do not want to use that time we can use Abstract class.
Vineet KumarRank #1,752 · 861 reputationPosted Mar 29, 2015, 9:04 PM EDT
1. Abstract class can have some methods implemented while interface doesn't allow you to implement any method inside it.
2. Interface allow us to use multiple inheritance while abstract class doesn't.
3. An abstract class defines the core identity of a class whereas interface defines peripheral abilities of a class. Abstract class is used for the same type of objects but interfaces can be used for different type of objects.
For example human and vehicle both can implement IMovable which will have a move method.
Abstract class acts as a base class for other classes. if you have some common implementations for all the classes you should go for abstract class.