79 words
1 minutes
Abstract Class vs Interface in Java
2025-01-21

Difference between Abstract class and Interface#

PointsAbstract ClassInterface
Type of MethodsCan have both abstract and concrete methodsCan have only abstract methods (until Java 7), from Java 8 can have default and static methods, and from Java 9 can have private methods
VariablesCan have final, non-final, static, and non-static variablesOnly static and final variables
InheritanceCan extend only one class (abstract or not)A class can implement multiple interfaces
ConstructorsCan have constructorsCannot have constructors
ImplementationCan provide the implementation of interface methodsCannot provide the implementation of abstract class methods
Abstract Class vs Interface in Java
https://shinbun.vercel.app/posts/java-abstract-interface/java-abstract-interface/
Author
Lưu Cao Hoàng | ホアン・カオ・ルウ | Hoang Cao Luu
Published at
2025-01-21