Interfaces and Obligations

A developer who creates a class that implements RocketSim is responsible for writing apogee() and thrust() methods that return measures of a rocket's performance. In other words, the developer must fulfill the contract implied by the method names and the code comments.

Sometimes, the methods that an interface designates do not carry an obligation to perform a service for the caller. In some cases, the implementing class can even ignore the call, implementing a method with no body whatsoever.

CHALLENGE 2.3Give an example of an interface with methods that do not imply responsibility on the part of the implementing class to take action on behalf of the caller or to return a value.

If you create an interface that specifies ...

Get Design Patterns Java™ Workbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.