Difference between Abstract class and Interface?

Abstract Class
Interface
An Abstract class is written when there are some common features shared by all the objects.

An Interface is written when all the features are implemented differently in different objects.

When an abstract class is written ,it is duty of the programmer to provide sub classes to it

An Interface is written when the programmer wants   to leave the implementation to the third party vendors.

All the abstract methods of the abstract class should be implemented in its subclasses.

All the methods (abstract) of interface should be implemented in its implemented classes.

An abstract class contains some abstract methods and concrete methods .
i.e an Abstract class contains 0 or more abstract methods

Only abstract methods
Abstract class can contain instance and static variables

Interface can contain only static variables.

Multiple inheritance is not allowed through class

Multiple inheritance is possible through interface  

Abstract class can contain constructor

Interface can’t contain constructor

Use abstract keyword

Use interface keyword

3 comments :