Ordinary Interfaces

Design Patterns (Gamma et al. 1990) frequently mentions the use of abstract classes but does not describe the use of interfaces. The reason is that the languages C++ and Smalltalk, which Design Patterns uses for its examples, do not have an interface construct. This omission has a minor impact on the utility of the book for Java developers, because Java interfaces are quite similar to abstract classes.

CHALLENGE 2.1Write down three differences between abstract classes and interfaces in Java.

The basic definition of Java interfaces is not complex. However, you should be aware of a few subtle points when using them.

Consider the definition of an Oozinoz interface that rocket simulation classes must implement. Engineers design ...

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.