Abstract
- An abstract class can’t be instantiated, but it can be subclassed. An abstract class usually contains abstract and non-abstract methods that subclasses are forced to provide an implementation for.
- Abstract class doesn’t support multiple inheritance
- Abstract class can have final, non-final, static and non-static variables
- Abstract class can have static methods, main method and constructor
- Abstract class can provide the implementation of interface
- The abstract keyword is used to declare abstract class.
- Abstract classes can be indirectly instantiated via subclasses
Interface
- An interface is a completely “abstract class” that is used to group related methods with empty bodies.
- You can use an interface to define a contract/template for the objects to follow. So, any class that implements the interface, they have to use all the methods in the interface.
- Interface can have only abstract methods
- Interface supports multiple inheritance
- Interface has only static and final variables
- Interface can’t have static methods (until Java 8), main method or constructor.
- Interface can’t provide the implementation of abstract class
- The interface keyword is used to declare interface