Engineering Questions with Answers - Multiple Choice Questions

MCQs on The Prototype Pattern, Reactor Pattern and Command Pattern

1 - Question

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 - Question

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 - Question

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.




4 - Question

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 - Question

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 - Question

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 - Question

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.




8 - Question

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 - Question

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.




10 - Question

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.

Get weekly updates about new MCQs and other posts by joining 18000+ community of active learners