250+ TOP MCQs on The Controller Component and Answers

JUnit Multiple Choice Questions & Answers (MCQs) on “The Controller Component”.

1. The ______ is a component that “interacts with a client, controlling and managing the handling of each request”.
a) Master
b) RequestHandler
c) Controller
d) Class
Answer: c
Clarification: A controller is a component that “interacts with a client, controlling and managing the handling of each request,” and tells that it is used in both presentation-tier and business-tier patterns.

2. An example of a web controller is __________
a) Apache Struts Framework
b) JUnit
c) Java
d) Php
Answer: a
Clarification: Apache Struts Framework is an open source framework for building Servlet/JSP based web applications which is an example of a web controller.

3. What are the object(s) which make the core of the description of a controller component?
a) The Request, the Response
b) The Request, the Response, the RequestHandler, and the Controller
c) The Request
d) The RequestHandler
Answer: b
Clarification: The flow of control is from the Request interface to the Response interface to the RequestHandler interface finally to the Controller Interface.

4. What is the signature of the addHandler method of the Controller interface?
a) void addHandler(Request request, RequestHandler requestHandler)
b) void addHandler(RequestHandler requestHandler);
c) void addHandler(RequestHandler requestHandler);
d) void addHandler(Request request, Request requestHandler);
Answer: a
Clarification: The addHandler method takes a Request and then a RequestHandler to handle that request as parameters.

5. The principle of “Hollywood Principle: Don’t call us, we’ll call you” is commonly known as _____________
a) Calling Principle
b) Control Call
c) Inversion of Control
d) No-Show Principle

Answer: c
Clarification: Inversion of Control on separating what to do from when to do.

6. Inversion of Control is used to increase __________ of the code.
a) Functionality
b) Cleanliness
c) Effectiveness
d) Modularity
Answer: d
Clarification: Inversion of control makes the code more extensible resulting in more modular code.

7. When the container calls setter methods after invoking a constructor with no arguments it is known as ________________
a) Constructor-based dependency injection
b) Setter-based dependency injection
c) Setter-Seller dependency injection
d) No-Constructor dependency injection
Answer: b
Clarification: Setter-based DI is accomplished by the container calling setter methods on your beans after invoking a no-argument constructor or no-argument static factory method.

8. Constructor-based DI is accomplished when the container invokes a class constructor with ____________
a) A number of arguments
b) No argument
b) Just one argument
c) Null objects
Answer: a
Clarification: Each argument represents a dependency on some other class.

9. Constructor-based DI is preferred for ___________
a) Optional dependencies
b) Mandatory dependencies
c) All dependencies
d) No dependency
Answer: b
Clarification: Since there has to be at least one argument, Constructor-based DI is preferred for Mandatory dependencies.

10. In the context of unit testing, the term ___________ is used to contrast and compare the objects you use in your application with the objects that you use to test your application (test objects).
a) Mock Object
b) Dummy Object
c) Domain Object
d) Real Object
Answer: c
Clarification: Any object under test is considered a domain object.

  250+ TOP MCQs on Testing in the Development Cycle and Answers

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top