Summary
The basic purpose of a Java interface is to declare a set of methods that a class implements. This usually implies that the class provides the services that the method names suggest. An exception to this responsibility occurs when the interface lets an object register for event notification. In this situation, the client of the interface bears responsibility for calling the interface methods when the events implied by the method names occur. When you create a registration interface, it is useful to pair the interface with an abstract class that provides empty implementations of the interface methods, simplifying registration. Interfaces and classes can also collaborate in the use of constants, with interfaces providing better readability ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access