when we go for abstract class and interface plz give me ans
thanks in advance
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Vineet KumarPosted Mar 30, 2015, 1:04 AM
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.
Saineshwar BageriPosted Mar 30, 2015, 12:31 AM
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.