Difference between Abstract Classes and Interfaces

Abstract ย Interface
Abstract class can have abstract and non-abstract methods ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย . Interface can have only abstract methods and abstract class can have field/property but interface not allow it.
Abstract class doesn’t support multiple inheritance Interface supports multiple inheritance.
Itย can use access modifier But interface wont have it because within an interface by default everything is public
Itย can have final, static ,non-final and non-static variables Interface has only final variables and static
It can provide the implementation of interface Interface can’t provide the implementation of abstract class

 

Let us discuss the difference one by one with simple example.

Abstract class can have abstract and non-abstract methods. Interface can have only abstract methods and abstract class can have field/property but interface not allow it.

Abstract Class:

Interface : Wrong

Interface : With Proper

Note : In simple, An abstract class can has implementation or non-implemented methods but interface can’t have implementation for any of its method.

Abstract class doesn’t support multiple inheritance. Interface supports multiple inheritance.

It’s not possible to inherite more than one abstract class. For example, if we having two abstract class namely Employee , EmployeePersonalDetails.

Abstract: Error

Interface: It support multiple inheritance

ย An abstract class can access modifier but interface wont have it because within an interface ย  everything is public in default.

Interface :ย Incorrect

Interface : Correct

 

ย