JUnit Questions and Answers – In-container Testing

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

Answer: a
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

Answer: c
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

Answer: d
Explanation: Jetty was originally known as IssueTracker as that was its original application.
advertisement
advertisement

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

Answer: a
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

Answer: b
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

Answer: c
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

Answer: b
Explanation: The parameter of the constructor, in this case 8080, represents the port number.
advertisement

8. The ______________ method sets the document root from which to serve resources.
a) setResourceBase
b) resourceBase
c) setResource
d) setBase
View Answer

Answer: a
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

Answer: b
Explanation: The ResourceHandler is attached to serve files from the file system.
advertisement

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

Answer: a
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.

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.