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.
advertisement

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.

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.
advertisement

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.

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).

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.

advertisement
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN Architect and is passionate about competency developments in these areas. He lives in Bangalore and delivers focused training sessions to IT professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux Networking, Linux Storage, Advanced C Programming, SAN Storage Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber Channel. Stay connected with him @ LinkedIn