Summary of the similarities and differences between the Interfaces and Abstract class
| Abstract class | Interface | |
| Has a constructor | Yes | No |
| An instance can be created from it | No | No |
| Implemented as part of the Class Hierarchy. Uses Inheritance | Yes (In extendes clause) | No (In implements clause) |
| records and enums can extend or implement? | No | Yes |
| Inherits from java.lang.Object | Yes | No |
| Can have both abstract methods and concrete methods | Yes | Yes (as of JDK 8) |
| Abstract methods must include abstract modifier | Yes | No (Implicit) |
| Supports default modifier for it's methods | No | Yes (as of JDK 8) |
| Can have instance fields (non-static instance fields) | Yes | No |
| Can have static fields (class fields) | Yes | Yes - (implicitly public static final) |
No comments:
Post a Comment