This set of JUnit Multiple Choice Questions & Answers (MCQs) 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
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
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
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
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
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
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
Explanation: The DoAllAction class implements the Action interface.
8. ___________ returns an Enumeration over a collection.
a) ActionSequence
b) CustomAction
c) DoAllAction
d) ReturnEnumerationAction
View Answer
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
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
Explanation: The ThrowAction class throws an exception.
Sanfoundry Global Education & Learning Series – JUnit.
To practice all areas of Junit, here is complete set of 1000+ Multiple Choice Questions and Answers.
- Check JUnit Books
- Apply for Computer Science Internship
- Check Programming Books
- Practice Programming MCQs