Advanced
Object-Oriented Programming Concepts
Q92 / 100
How do "abstract classes" and "interfaces with default methods" (e.g. Java 8+ default methods) compare in terms of evolving APIs?
Correct! Well done.
Incorrect.
The correct answer is A) Default methods let interfaces add new methods with a default implementation without breaking existing implementing classes, narrowing (but not eliminating) the gap with abstract classes
A
Correct Answer
Default methods let interfaces add new methods with a default implementation without breaking existing implementing classes, narrowing (but not eliminating) the gap with abstract classes
Explanation
Before default methods, adding a new method to an interface broke all implementers; default methods allow backward-compatible interface evolution, though abstract classes still allow shared state (fields) which interfaces traditionally cannot.
Progress
92/100