This set of JUnit Multiple Choice Questions & Answers (MCQs) focuses 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
View Answer
Explanation: 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
View Answer
Explanation: 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
View Answer
Explanation: 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);
View Answer
Explanation: 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
View Answer
Explanation: Inversion of Control focuses 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
View Answer
Explanation: 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
View Answer
Explanation: 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
c) Just one argument
d) Null objects
View Answer
Explanation: 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
View Answer
Explanation: 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
View Answer
Explanation: Any object under test is considered a domain object.
Sanfoundry Global Education & Learning Series – JUnit.
To practice all areas of Junit, here is complete set of 1000+ Multiple Choice Questions and Answers.
If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]
- Apply for Computer Science Internship
- Practice Programming MCQs
- Check JUnit Books
- Check Programming Books