

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


This quiz is to be taken by yourself with closed books, closed notes, no electronic devices.
public class Foo { private volatile static Foo foo; private Foo() {} public static Foo x() { if ( foo == null ) { synchronized (Foo.class) { if ( foo == null ) foo = new Foo(); } } return foo; } // Other methods ... }
The main advantage(s) to the above pattern is we have: (Circle all that apply)
A) Lazy creation of the object B) Eager creation of the object C) Only synchronize the first time through D) No need to synchronize since we are using volatile static E) Users of this class only need to create one Foo object on their own to invoke Foo's other methods F) Synchronize each time to handle multiple threads
List all the targets in the order they would be run by ant if you entered the command:
ant get-good-grades
(Continued on other side)
A) Eager Singleton B) Lazy Abstract Factory C) Synchronized Decorator D) Double-Checked Locking Singleton E) Synchronized Observer
Relies on inheritance ______ Relies on object composition ______ Allow a class to defer object instantiation to its subclasses _______ Not a bona fide design pattern _______ Create families of related objects without having to depend on their concrete implementation ______ A variant of this is used to model the Singleton pattern ______
A) uses subclassing to extend behavior B) enables adding new behaviors at runtime C) enables adding new behaviors at compile time D) is used in the java.io package E) uses abstract (vs. concrete) classes to wrap a component with any number of decorators F) changes behavior of their components by adding new functionality usually before or after method calls to the component
What refactoring technique(s) is/are commonly used when the duplicate code is in several unrelated classes?
Give two advantages for using a Null Object vs. always checking/using null? For example, with a List what advantage does a Null List object provide vs. coding with only the null reference?
What is the name of the bad smell when one class spends most of its time/operations requesting/requiring private members from another class?
What refactoring technique would you use to take care of this bad smell?
A) Simple Factory B) Factory Method C) Abstract Factory