Sample Test Questions For Test 2
1) What pattern allows you to use an existing class when its interface does not match the one you need?
2) Which design pattern is illustrated by the implementation of the Java I/O classes?
3) Both the Observer and the Chain of Responsibility patterns attempt to decouple sending and receiving objects. Compare these two patterns with regard to such decoupling. 4) To improve web page download times, a designer thinks it would be a good idea to have the browser pre-fetch all of the pages referenced from the page the user is currently viewing. But rather than have each individual client pre-fetch the pages from remote web servers, it would be even better if all the pre-fetched pages for a group of clients could be made available locally. Select the most appropriate design pattern to use to address the problem and show how it is applied. In particular, show an appropriate class diagram(s) and enough code fragments to illustrate your use of the pattern to solve the problem. 5) Wile E. Coyote just bought a voice-activated Acme Big-Mouth Bass from his local Wal-Mart. The Acme Big-Mouth Bass is a 12-inch plastic fish mounted on a wooden plaque that sings” Don’t Worry, Be Happy”whenever it is activated. The incredibly lifelike, adorable fish can be activated by yelling “ you gotta be kidding!” very loudly or by pushing a button on the back of the plaque. Once the fish is activated and starts to sing its song, the Acme designers did not want additional button pushes or voice activations to extend the song cycle. Select the most appropriate design pattern(s) to use to address this problem and show how it is applied here. For this problem, show some example code that implements your pattern.
Select the most appropriate design pattern to use a address the problem and show how it is applied. In particular, show an appropriate class diagram(s) an enough code fragments to illustrate your use of the pattern to solve the problem.
6) Company X has a large amount of applications software written using a particular class library. Company Y that wrote the class library has now gone out of business. Company X buys a new class library from Company Z that provides the same functionality as the previous library, but unfortunately many of the classes have different interfaces. Company X does not have access to the source code for the old or the new library. What should Company X do??
Select the most appropriate design pattern to use to address the problem and show how it is applied. In particular, show an appropriate class diagram(s) an enough code fragments to illustrate your use of the pattern to solve the problem.