December 5, 2024
Object Oriented programming oop

Difference between Interface and Abstract Class

Interface and abstract class are almost same. That’s why we may confused. But they are not same, have some difference. This article explains the difference between abstract and interface. Summary of the article:

  • What is Abstract Class?
  • What is Interface?
  • Interface Vs Abstract Class

What is Abstract Class?
Abstract class is a class that contain abstract (incomplete) and non abstract (complete) both type of member and it cannot be instantiated. It is one of the essential behaviors provided by .NET technology.

What is Interface?
Interface is a template which contains only the signatures of methods,events or delegates. It has no implementation and the implementation is done by the class which implements the interface.

Interface Vs Abstract Class
Difference between abstract class and interface is given bellow:
Interface

  1. It support multiple inheritance    .
  2. It doesn’t contains Data Member.
  3. It doesn’t contains Constructors.
  4. It contains only abstract (incomplete) member.
  5. It cannot have access modifiers by default everything is assumed as public.
  6. Member of interface cannot be Static.

Abstract Class

  1. It does not support multiple inheritances.
  2. It contains Data Member.
  3. It contains Constructors.
  4. It contains both abstract (incomplete) and non abstract (complete) member.
  5. It can contain access modifiers for the subs, functions, properties
  6. Complete member of abstract class can be Static.

We should have a clear concept on interface and abstract class. We must need to know when to use interface and when to use abstract class. That’s all about abstract class vs interface.

Rashedul Alam

I am a software engineer/architect, technology enthusiast, technology coach, blogger, travel photographer. I like to share my knowledge and technical stuff with others.

View all posts by Rashedul Alam →

One thought on “Difference between Interface and Abstract Class

Leave a Reply

Your email address will not be published. Required fields are marked *