Difference between abstract class and interface

Difference between abstract class and interface

Before list the difference between abstract class and interface we need know little bit about them.Difference between abstract class and interface.

Abstract class is a class that can not be instantiated. It is only inherited by other class. An abstract class has abstract methods. In other words, A class must be declared abstract when it has one or more abstract methods.


An interface is not a class. It is an entity that is defined by the word Interface. An interface has no implementation, It means when we create interface , we create set of methods without any implementation. These methods are overridden by implemented classes.


Difference between abstract class and interface

  1. A class may inherit several interfaces,But a class may inherit only one abstract class.
  2. An interface does not have any implementation just method with empty body,whereas an abstract class can provide complete, default code and/or just the details that have to be overridden.
  3. In interface sub classes,functions,properties are publicly accessible.But an abstract class have access modifiers for the functions and method.
  4. If we add a new method to an Interface then we have to track down all the implementations of the interface and define implementation for the new method. But If we add a new method to an abstract class then we have the option of providing default implementation and therefore all the existing code might work properly
  5. In interface no fields can be defined. But in abstract class fields and constant can be defined.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.