Differences Between Abstract Class and Interface

Abstract class:

Abstract class must have at least one abstract method. 
Abstract keyword must be used for all the methods.
Abstract class must have subclass.


Inheritance is possible in interface.
Variables value must be defined in interface.
Many interface can be implemented by a single class.
Methods can be defined in interface and used in class.

Abstract classes are used when they have some sharable implementations and some specific methods left to subclasses to implement. Interface is used when there are no sharable implementation and the implementation changes frequently.

Abstract class can have methods which are abstract or not abstract. All methods of interface should be implemented unless the implementation is an abstract class.

Abstract class can be subclassed interface class can be implemented

No comments:

Post a Comment

Please Provide your feedback here