Design Patterns QA 1 13 1
Design Patterns QA 1 13 1
Design Patterns QA 1 13 1
Q 2 - If we serialize a singleton object and deserialize it then the result object will
be same.
A - true
B - false
Answer : B
Explanation
false. Deserializing a serialized object will yield a different object.
-1-
D - This pattern is used when there is one-to-many relationship between objects
such as if one object is modified, its depenedent objects are to be notified
automatically.
Answer : C
Explanation
This pattern is used to restore state of an object to a previous state.
Answer : C
Explanation
Structural design patterns concern class and object composition. Concept of
inheritance is used to compose interfaces and define ways to compose objects to
obtain new functionalities.
Answer : B
Explanation
Prototype pattern refers to creating duplicate object while keeping performance in
mind.
-2-
Q 9 - Which of the following describes the Decorator pattern correctly?
A - This pattern allows a user to add new functionality to an existing object without
altering its structure.
B - This pattern is used where we need to treat a group of objects in similar way as
a single object.
C - This pattern hides the complexities of the system and provides an interface to
the client using which the client can access the system.
D - This pattern is primarily used to reduce the number of objects created and to
decrease memory footprint and increase performance.
Answer : A
Explanation
Decorator pattern allows a user to add new functionality to an existing object
without altering its structure.
Answer : C
Explanation
Memento pattern is used to restore state of an object to a previous state.
Answer : C
Explanation
In Strategy pattern, a class behavior or its algorithm can be changed at run time.
-3-
Q 13 - Which type of design patterns provide a way to create objects while hiding
the creation logic, rather than instantiating objects directly using new opreator?
A - Creational Design Patterns
B - Structural Design Patterns
C - Behavioral Design Pattern
D - J2EE Design Patterns
Answer : A
Explanation
Creational Design Patterns provide a way to create objects while hiding the creation
logic, rather than instantiating objects directly using new opreator.
-4-