April 06, 2020 /   Interfaces   Abstract class   Differences   Java 8

Interface vs Abstract class

After roll-out of Java 8, much has been changed in Core Java language concepts. Primarily being an Object oriented programming, Java has provided Functional Language aspects too using Lambda expressions and Map & Reduce features. But at the core it is still using Object oriented concepts.

A lot has been changed in Interfaces too so that the old school differences between Java Interfaces and Abstract classes might have been outdated.

Java 8 has introduced following new features in Interfaces.

  1. Default methods - to provide default implementation of abstract methods, if implementing class does not override them, default implementation will be available and implementation class is not forced to override.

  2. Static methods - can be used to defile utility methods, implementing class can not override them

Both of the above features are provided to remove Utility classes and common code. For example Collections class can be made redundant by moving its functions to Interfaces like List and Collections.

With the introductions of these features in interfaces we can re-define differences between interfaces and abstract classes in this infographic

Interface vs Abstract class

Related Posts

What's new in Java 15?

Java 14 (JDK 14) Features