Search

Java Interfaces vs. Abstract class

Summary of the similarities and differences between the Interfaces and Abstract class


Abstract classInterface
Has a constructorYesNo
An instance can be created from itNoNo
Implemented as part of the Class Hierarchy. Uses InheritanceYes (In extendes clause)No (In implements clause)
records and enums can extend or implement?NoYes
Inherits from java.lang.ObjectYesNo
Can have both abstract methods and concrete methodsYesYes (as of JDK 8)
Abstract methods must include abstract modifierYesNo (Implicit)
Supports default modifier for it's methodsNoYes (as of JDK 8)
Can have instance fields (non-static instance fields)YesNo
Can have static fields (class fields)YesYes - (implicitly public static final)




No comments:

Post a Comment

Java Interfaces vs. Abstract class

Summary of the similarities and differences between the Interfaces and Abstract class Abstract class Interface Has a constructor Yes No An i...