Abstract class: In java, an abstract class is a class that is partially implemented. It provides design convenience. An abstract class is made up of one or more abstract methods that are declared but left unimplemented.
Interface: An interface is a reference type that defines a contract. An interface body consists of method declarations and constants. All methods and constants in an interface are public. Interfaces are left completely unimplemented, i.e., no method in the interface is implemented. All methods of an interface are abstract and the method body is absent.
The following table depicts the difference between abstract class and interfaces:
| Abstract class | Interface |
|---|---|
| It is declared with the keyword abstract. | It is declared with the keyword interface. |
| It can contain non-abstract methods. | By default all the methods of an interface are abstract. |
| An abstract class can contain private methods. | An interface cannot contain private methods. |
| It can contain instance variables and final varibales. | It contains final varibales only. |
Responses to “Difference between abstract classes and interfaces”