Software Design Questions and Answers – The Prototype Pattern, Reactor Pattern and Command Pattern

This set of Software Design Interview Questions and Answers focuses on “The Prototype Pattern,Reactor Pattern and Command Pattern”.

1. Which of the following are true for prototype pattern?
a) A clone is a copy of an object
b) When values stored in an entity (including references) are reproduced in the copy, the copy operation is said to be shallow
c) In contrast, a copy operation is deep when copies are made of all referenced entities in the original composite, and references to the new entities are placed in the copy
d) All of the mentioned
View Answer

Answer: d
Explanation: All of the mentioned are true.

2. Any class using the built-in cloning mechanism is supposed to do which of the following?
a) Implement the Cloneable interface
b) Define a concrete public or protected clone() operation
c) In the clone() operation, obtain a new object by calling super.clone()
d) All of the mentioned
View Answer

Answer: d
Explanation: All of the mentioned are true.

3. Which of the following are correct for copy constructor?
a) A copy constructor is a constructor that takes an instance of its class as an argument and creates a clone of its argument
b) A copy constructor must be used when a final field must be set in creating the clone because only a constructor can set a final field
c) All of the mentioned
d) None of the mentioned
View Answer

Answer: d
Explanation: All of the mentioned are true.
advertisement
advertisement

4. Which of the following pattern has Step up phase as its activity?
a) Prototype pattern
b) Reactor Pattern
c) Command pattern
d) None of the mentioned
View Answer

Answer: b
Explanation: Reactor pattern has two phases-Step up phase and Operational Phase.

5. What happen in the operational phase of Reactor pattern?
a) The Client registers the Reactor with the Target
b) The Reactor responds to event notifications from the Target
c) All of the mentioned
d) None of the mentioned
View Answer

Answer: c
Explanation: The operational phase of Reactor pattern-The Reactor responds to event notifications from the Target.

6. The reactor patterns provide a good model for event-driven portions of a program for which of the following reasons?
a) Client and Target Decoupling
b) Client Decomposition
c) Operation Encapsulation
d) All of the mentioned
View Answer

Answer: d
Explanation: All of the mentioned are correct reasons.

7. Which of the following are consequences for command pattern?
a) Reactor patterns provide event-driven design models
b) They decouple clients and targets
c) Encapsulate reactions to event
d) None of the mentioned
View Answer

Answer: d
Explanation: All are the consequences for Reactor pattern.
advertisement

8. Which among these are advantages for Function Class?
a) Additional features can be added to the function class, enhancing its capabilities
b) The function class can include other data and operations the encapsulated operation needs
c) All of the mentioned
d) None of the mentioned
View Answer

Answer: c
Explanation: All of the mentioned are advantages.

9. Which of the several aspects of the Command pattern may be varied or elaborated to help achieve particular design goals
a) An invoker may accept registration of more than one command
b) The invoker may offer operations for un-registering one or more commands
c) An invoker may offer several kinds of registrations for different kinds of events
d) All of the mentioned
View Answer

Answer: d
Explanation: All of the mentioned are the goals.
advertisement

10. Which of the following are the consequences for Command pattern?
a) Event-driven design is facilitated
b) Making event-handling code easy to find, change, and reuse
c) The invoker is loosely coupled to both the command and client classes,making them easy to change
d) All of the mentioned
View Answer

Answer: d
Explanation: All of the mentioned are the consequences.

Sanfoundry Global Education & Learning Series – Software Architecture and Design.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.