JUnit Questions and Answers – Maven Introduction

This set of JUnit Multiple Choice Questions & Answers (MCQs) focuses on “Maven Introduction”.

1. The __________ package contains plugins that make it easier to use jMock with legacy code.
a) org.jmock.api
b) org.jmock.lib.action
c) org.jmock.lib.script
d) org.jmock.lib.legacy
View Answer

Answer: d
Explanation: org.jmock.lib.legacy contains several plugins that make it suitable to use jMock with legacy code.

2. _____________ class enables to imposterise abstract and concrete classes without calling the constructors of the mocked class.
a) ClassImposteriser
b) Imposteriser
c) ImposterisingClass
d) Imposter
View Answer

Answer: a
Explanation: The ClassImposteriser implements Imposteriser interface.

3. ________ method reports if the Imposteriser is able to imposterise a given type.
a) canImposterise(Class<?> type)
b) Imposterise(Class<?> type)
c) imposterise(Invokable mockObject, Class<T> mockedType, Class<?>… ancilliaryTypes)
d) imposter()
View Answer

Answer: a
Explanation: canImposterise(Class<?> type) returns true if this imposteriser can imposterise type, false otherwise.
advertisement
advertisement

4. ___________ creates an imposter for a given type that forwards Invocations to an Invokable object.
a) canImposterise(Class<?> type)
b) Imposterise(Class<?> type)
c) imposterise(Invokable mockObject, Class<T> mockedType, Class<?>… ancilliaryTypes)
d) imposter()
View Answer

Answer: c
Explanation: imposterise(Invokable mockObject, Class<T> mockedType, Class<?>… ancilliaryTypes) returns a new imposter. The imposter must implement the mockedType and all the ancialliaryTypes.

5. The mockObject parameter of imposterise() is the class representing the static type of the imposter.
a) True
b) False
View Answer

Answer: b
Explanation: The mockType parameter of imposterise() is the class representing the static type of the imposter.

6. The ancilliaryTypes parameter of the imposterise() function must all be interfaces.
a) True
b) False
View Answer

Answer: a
Explanation: The types must all be interfaces because Java only allows single inheritance of classes.

7. The __________ package contains plugins that make it easier to write custom actions by scripting their behaviour with BeanShell.
a) org.jmock.api
b) org.jmock.lib.action
c) org.jmock.lib.script
d) org.jmock.lib.legacy
View Answer

Answer: c
Explanation: org.jmock.lib.script is the package containing plugins to write custom actions by scripting.
advertisement

8. ___________ class is an Action that executes a BeanShell script.
a) ScriptedAction
b) Scripted
c) Action
d) ScriptedActionClass
View Answer

Answer: a
Explanation: ScriptedAction class makes it easy to implement custom actions.

9. ______________ method performs an action in response to an invocation.
a) describeTo(Description description)
b) invoke(Invocation invocation)
c) perform(String script)
d) where(String name, Object value)
View Answer

Answer: b
Explanation: invoke(Invocation invocation) returns the result of the invocation, if not throwing an exception.
advertisement

10. The invoke method throws which exception?
a) ArrayIndexOutOfBounds
b) StringIndexOutOfBounds
c) Throwable
d) NullPointer
View Answer

Answer: c
Explanation: Any checked exception thrown must be in the throws list of the invoked method.

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.