Introducing Operations (Chapter 20)

SOLUTION 20.1CHAIN OF RESPONSIBILITY distributes an operation across a chain of objects. Each method implements the operation's service directly or forwards calls to the next object in the chain.
SOLUTION 20.2The figure shows one algorithm—the procedure to determine whether an object model is a tree—two operations,which appear as two signatures in the MachineComponent class, and four methods.
SOLUTION 20.3No. If you change the return value of MachineSimulator.clone(), it won't compile. The clone() signature matches the signature of Object.clone(), so the return type must match as well.
SOLUTION 20.4The program prints "false". Static methods are invoked with reference to an object's declared type, not with reference ...

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.