JUnit Questions and Answers – The Mock Objects Solution

This set of JUnit Questions and Answers for Campus Interviews focuses on “The Mock Objects Solution”.

1. Using old tests to guard against new changes is a form of ______________
a) Unit Testing
b) Integration Testing
c) Regression Testing
d) Loss Testing
View Answer

Answer: c
Explanation: The best way to ensure that regression testing takes place is to automate the test suites.

2. A ________ is a piece of code that’s inserted at runtime in place of the real code.
a) Stub
b) Mock Object
c) Packet
d) Jammer
View Answer

Answer: a
Explanation: Stubs are used in order to isolate the caller from the real implementation.

3. The intent of using stubs is to replace a _________ behaviour with a simpler one.
a) Unique
b) Complex
c) Redundant
d) Anomalous
View Answer

Answer: b
Explanation: Stubs allow independent testing of some part of the real code.
advertisement
advertisement

4. Stubs usually provide high _____________ in the tested system.
a) Mocking
b) Security
c) Confidence
d) Modularity
View Answer

Answer: c
Explanation: With stubs, the objects under test aren’t getting modified.

5. Stubs don’t lend themselves well to ____________ unit testing.
a) Fine-grained
b) Coarse-grained
c) Redundant
d) Functional
View Answer

Answer: a
Explanation: In general, stubs are better adapted for replacing coarse-grained portions of code.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

6. A build or developer usually executes tests involving stubs in their _________ environment.
a) Dead
b) Running
c) Production
d) Fake
View Answer

Answer: b
Explanation: Executing in the running environment provides additional confidence.

7. An implementation that returns a hardcoded value for purposes of testing is known as a __________
a) Stub
b) Mock Object
c) Packet
d) Jammer
View Answer

Answer: a
Explanation: A stub implementation can be created dynamically using lambdas.
advertisement

8. _____________ is a software testing technique that is useful to help in the generation of test data.
a) Symbolic Execution
b) Stubs
c) Active testing
d) All-pairs testing
View Answer

Answer: a
Explanation: Symbolic Execution is used in proving the program quality.

9. The ______________ identifies the decision points and the assignments associated with each flow.
a) Decision Table
b) Flowgraph
c) Testing Design
d) Audit
View Answer

Answer: b
Explanation: Traversing the flow graph from an entry point is used to produce a list of assignment statements and branch predicates.
advertisement

10. Symbolic execution is not able to proceed if the number of iterations in the loop is known.
a) True
b) False
View Answer

Answer: a
Explanation: Symbolic execution can also not be used with arrays.

Sanfoundry Global Education & Learning Series – JUnit.
To practice all areas of JUnit for Campus Interviews, 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.