Difference Between Abstract and Interface
Abstract class and interface both are used to achieve abstraction where can declare the abstract methods.
A category that has the abstract keyword in its declaration is termed abstract class. Abstract categories ought to have a minimum of one abstract methodology. The strategies while not a body. It will have multiple concrete strategies.
Abstract categories permit you to make blueprints for concrete categories however the heritable category ought to implement the abstract methodology. Abstract categories can not be instantiated.
There are two abstracts class have a abstract and non-abstract methods. It does not support multiple inheritance. It has final , non-final, static and non-static variables. It can provide the implementation of interface. The keyword is used to declare abstract class.
An abstract extends keywords are used. It can have class members like private, protected, etc.
Interface can have only abstract methods. Since java 8, it can have default and static methods also. Interface could be a blueprint which will be accustomed implement a category. The interface doesn’t contain any concrete strategies. All the strategies of an interface square measure abstract strategies.
An interface can’t be instantiated. However categories that implement interfaces may be instantiated. Interfaces never contain instance variables however, they will contain public static final variables.
- Interface supports multiple inheritance.
- Interface has only static and final variables.
- Interface can’t provide the implementation of abstract class.
- The interface keyword is used declare interface.
- An interface can extend another java interface only.
- An interface can be implemented using keyword implements.
- Members of a java interface are public by default.