JUnit Questions and Answers – Setting Up a Maven Project

This set of JUnit Problems focuses on “Setting Up a Maven Project”.

1. ___________ creates an action that performs the given script.
a) describeTo(Description description)
b) invoke(Invocation invocation)
c) perform(String script)
d) where(String name, Object value)
View Answer

Answer: c
Explanation: The perform methods takes a BeanShell script as a parameter.

2. ____________ defines a variable that can be referred to by the script.
a) describeTo(Description description)
b) invoke(Invocation invocation)
c) perform(String script)
d) where(String name, Object value)
View Answer

Answer: d
Explanation: The where() function returns the action, so that more variables can be defined if needed.

3. ____________ package contains actions that fake the behavior of mocked invocations.
a) org.jmock
b) org.jmock.lib.action
c) org.jmock.lib
d) org.jmock.lib.script
View Answer

Answer: b
Explanation: org.jmock.lib.action contains actions that fake the behavior of mocked invocations.
advertisement
advertisement

4. _____________ returns the next of a sequence of elements each time it is invoked.
a) ActionSequence
b) CustomAction
c) DoAllAction
d) ReturnValueAction
View Answer

Answer: a
Explanation: The ActionSequence methods takes as a parameter the invocation to perform.

5. The exception thrown by the ActionSequence mehod is _____________
a) NullPointer
b) Throwable
c) ArrayIndexOutOfBounds
d) Arithmetic
View Answer

Answer: b
Explanation: Any checked exception thrown must be in the throws list of the invoked method.
Note: Join free Sanfoundry classes at Telegram or Youtube

6. ______________ is a partial implementation of the Action interface that making it easy to implement actions specific to applications with inline anonymous classes.
a) ActionSequence
b) CustomAction
c) DoAllAction
d) ReturnValueAction
View Answer

Answer: b
Explanation: The CustomAction class is a partial implementation of the Action interface.

7. _____________ performs multiple actions every time it is invoked.
a) ActionSequence
b) CustomAction
c) DoAllAction
d) ReturnValueAction
View Answer

Answer: c
Explanation: The DoAllAction class implements the Action interface.
advertisement

8. ___________ returns an Enumeration over a collection.
a) ActionSequence
b) CustomAction
c) DoAllAction
d) ReturnEnumerationAction
View Answer

Answer: d
Explanation: The class definition is public ReturnEnumerationAction(Object… array).

9. ___________ returns an iterator over a collection.
a) ActionSequence
b) CustomAction
c) ReturnIteratorAction
d) ReturnEnumerationAction
View Answer

Answer: c
Explanation: The constructors are public ReturnIteratorAction(Collection<?> collection) and public ReturnIteratorAction(Object… array).
advertisement

10. The VoidAction class throws an exception.
a) True
b) False
View Answer

Answer: b
Explanation: The ThrowAction class throws an exception.

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