Differences Between Interface and Abstract Class in Java

Before Java 8, there were many more differences between interfaces and abstract classes, but with the introduction of default, non-abstract, and static methods in interfaces, the difference has narrowed significantly.

See what still stands as the difference between these two types:

Abstract Class Interface
Methods Can have final methods but can not have default methods. Supports default methods but can not have final methods declared.
Fields It can have static, non-static, and final and non-final variables.
It also supports private, protected, and public variables.
Don’t support non-static and non-final variables.

Can have only public, static and final variables.

Constructors Can have any number of constructors. Can’t have constructors.
Member’s Accessibility Support all types of members – private, protected, and public. Don’t support protected members.
(private – yes, after Java 9)
Inheritance It can extend only one class but can implement multiple interfaces. It can extend multiple interfaces but can not extend a class.



Leave a Reply

Your email address will not be published.