World 10 of 26 · Intermediate

🔌 Interfaces & Abstraction

12 Java concepts, each explained step by step with real code, a common trap and practice questions.

  1. Interfaces as contractsWhat a type can do, not how; implements.
  2. Implementing multiple interfacesA class can implement many interfaces.
  3. Interface constantsFields are implicitly public static final.
  4. Default methodsInterface methods with a body; enable API evolution.
  5. Diamond conflictsTwo defaults with the same signature must be resolved with X.super.m().
  6. Static & private interface methodsHelpers in interfaces; static ones are not inherited by implementers.
  7. Abstract class vs interfaceState and constructors vs multiple inheritance of type.
  8. Functional interfacesExactly one abstract method; @FunctionalInterface.
  9. Marker interfacesSerializable, Cloneable and why annotations often replace them.
  10. Programming to an interfaceList<String> list = new ArrayList<>() and loose coupling.
  11. Comparable as an interface exampleNatural ordering via compareTo.
  12. Sealed classes & interfacessealed + permits restrict who can extend; final, sealed, non-sealed subclasses.