Difference-between-interface-and-abstract-class

Last modified on June 01, 2020 by DigitalIndiaInfo Team.

What is an Abstract Class?

An abstract class is a special kind of class that cannot be instantiated. An abstract class is only to be sub-classed or inherited from. In other words, it only allows other classes to inherit from it but cannot be instantiated. In simple words, it is a kind of contract that forces all the subclasses to carry on the same hierarchies or standards.

What is an Interface?

An interface is not a class. It is an entity that is defined by the word Interface. An interface has no implementation; it only has the signature or in other words, just the definition of the methods without the body. The main difference between them is that a class can implement more than one interface but can only inherit from one abstract class. Since C# doesn’t support multiple inheritance, interfaces are used to implement multiple inheritance.

Some Important Difference Between in Interface and Abstract class is below :

1. A class can implement any number of interfaces but a subclass can at most use only one abstract class.
 
2. An abstract class can have non-abstract Methods(concrete methods) while in case of Interface all the methods has to be abstract.
 
3. An abstract class can declare or use any variables while an interface is not allowed to do so.
 
4. An abstract class can have constructor declaration while an interface can not do so.
 
5. An abstract Class is allowed to have all access modifiers for all of its member declaration while in interface we can not declare any access modifier(including public) as all the members of interface are implicitly public.