This set of JUnit Multiple Choice Questions & Answers (MCQs) focuses on “In-container Testing”.
1. When unit testing, it’s important to be able to control as much as possible of the environment in which the tests execute.
a) True
b) False
View Answer
Explanation: This ensures that the test results are reproducible.
2. _______________ is a Java HTTP (Web) server and Java Servlet container.
a) Maven
b) Ant
c) Jetty
d) Zimbra
View Answer
Explanation: Jetty is often used for machine to machine communications, usually within larger software frameworks.
3. Jetty was originally called ________________
a) Eclipse
b) Maven
c) Ant
d) IssueTracker
View Answer
Explanation: Jetty was originally known as IssueTracker as that was its original application.
4. To create a Jetty server object, we have to import _____________
a) org.mortbay.jetty.Server;
b) org.jetty.Server;
c) org.junit.jetty.Server;
d) org.junit.Server;
View Answer
Explanation: The Jetty Server is found in “org.mortbay.jetty.Server”.
5. In Jetty, ____________ object processes the HTTP requests.
a) Server
b) Context
c) Root
d) Handler
View Answer
Explanation: Context object processes the HTTP requests and passes them to various handlers.
6. To create a Jetty context object, we have to import _____________
a) org.mortbay.jetty.Context;
b) org.jetty.Context;
c) org.mortbay.jetty.servlet.Context;
d) org.junit.Server;
View Answer
Explanation: The Jetty Server is found in “org.mortbay.jetty.servlet.Context”.
7. While creating a server object like- Server obj = new Server(8080), 8080 represents the number of connections.
a) True
b) False
View Answer
Explanation: The parameter of the constructor, in this case 8080, represents the port number.
8. The ______________ method sets the document root from which to serve resources.
a) setResourceBase
b) resourceBase
c) setResource
d) setBase
View Answer
Explanation: The setResourceBase method is used to set the document root from which resources will be served.
9. A _____________ handler is attached to the root to serve files from the file system.
a) SourceHandler
b) ResourceHandler
c) AttachHandler
d) RootHandler
View Answer
Explanation: The ResourceHandler is attached to serve files from the file system.
10. The ResourceHandler is found in the package ________________
a) org.mortbay.jetty.handler.ResourceHandler
b) org.jetty.handler.ResourceHandler
c) org.mortbay.junit.handler.ResourceHandler
d) org.junit.jetty.handler.ResourceHandler
View Answer
Explanation: The ResourceHandler class is a part of the handler package found at “org.mortbay.jetty.handler.ResourceHandler”.
Sanfoundry Global Education & Learning Series – JUnit.
To practice all areas of Junit, here is complete set of 1000+ Multiple Choice Questions and Answers.
- Apply for Computer Science Internship
- Practice Programming MCQs
- Check Programming Books
- Check JUnit Books