March 2002
Intermediate to advanced
496 pages
8h 51m
English
| SOLUTION 15.1 | The point of making the Reservation constructor protected is that it limits the ability to instantiate your class. You want to compel other developers to create Reservation objects with a builder rather than with the Reservation constructor. You could make the constructor package protected, which would ensure that only other classes within your package can construct Reservation objects. Making the constructor protected leaves open the possibility of subclassing Reservation from another package. Note that making the constructor's visibility private would break the builder classes' ability to instantiate the Reservation class. |
| SOLUTION 15.2 | The build() method of UnforgivingBuilder throws an exception if any attribute ... |
Read now
Unlock full access