How do 'Default Methods' in interfaces change the traditional definition of an interface?
Last updated
Default methods let an interface provide concrete
defaultmethod bodies, so interfaces are no longer purely abstract. They mainly enable adding methods without breaking existing implementers (e.g.Iterable.forEach).This blurs the line with abstract classes, but interfaces still hold no instance state and allow multiple inheritance of type.
If two interfaces supply the same default method, the implementing class must override it to resolve the conflict.
- https://www.digitalocean.com/community/tutorials/java-8-interface-changes-static-method-default-method
- https://interview-hub.in/Pages/java-abstraction-questions.html
- https://interviewprep.org/java-8-interview-questions/
- https://medium.com/@cs.vivekgupta/java-interview-questions-series-15-89d98025d083
- https://dev.to/be11amer/default-and-static-methods-in-interfaces-18if