JUnit Questions and Answers – Ant

«
»

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

1. Mocks are Trojan horses because they replace real ___________ from the inside, without the calling classes being aware of it.
a) Methods
b) Objects
c) Variables
d) Classes
View Answer

Answer: b
Explanation: Mocks have access to internal information about the class, making them quite powerful.

2. When we’re talking about mock objects, a/an _________ is a feature built into the mock that verifies whether the external class calling this mock has the correct behavior.
a) Expectation
b) Explanation
c) Behavior
d) Amorous
View Answer

Answer: a
Explanation: For example, a database connection mock could verify that the close method on the connection is called exactly once during any test that involves code using this mock.

3. EasyMock instantiates an object based on an interface or class.
a) True
b) False
View Answer

Answer: a
Explanation: EasyMock is used to make mock objects which is based on the interface or class being called or extended.
Note: Join free Sanfoundry classes at Telegram or Youtube
advertisement
advertisement

4. EasyMock relies heavily on the __________import feature of Java.
a) Dynamic
b) Static
c) Class
d) Object
View Answer

Answer: b
Explanation: All EasyMock imports are static imports.

5. To use the createMock method of EasyMock we need to import ___________
a) org.easymock.EasyMock.createMock
b) org.EasyMock.createMock
c) org.easymock.createMock
d) org.createMock
View Answer

Answer: a
Explanation: The EasyMock methods are found under “org.easymock.EasyMock.*”.

6. __________ method creates a mock object that implements the given interface, order checking is enabled by default.
a) createNiceControl
b) createMockBuilder
c) createNiceMock
d) createStrictMock
View Answer

Answer: d
Explanation: createStrictMock is the old version of strictMock(String, Class), which is more completion friendly.

7. ___________ is used for the creation of a mock object, with the specification of it being of the requested type, which has implementations of the given interface or extends the given class.
a) createMock(Class<T> toMock)
b) createMock(MockType type, Class<T> toMock)
c) createMock(String name, Class<T>toMock)
d) createMock(String name, MockType type, Class<T>toMock)
View Answer

Answer: b
Explanation: createMock(MockType type, Class<T> toMock) is the old version of mock(MockType, Class), which is more completion friendly.
advertisement

8. __________________ creates a mock object, of the requested type and name which are passed, which also has implementations of the given interface or extends the given class.
a) createMock(Class <T> toMock)
b) createMock(MockType type, Class<T> toMock)
c) createMock(String name, Class<T> toMock)
d) createMock(String name, MockType type, Class<T> toMock)
View Answer

Answer: d
Explanation: The name is passed as a parameter in the function definition.

9. ______________ creates a mock object that implements the given interface with the specification is that order checking is disabled by default.
a) createMock(Class<T> toMock)
b) createMock(MockType type, Class<T>toMock)
c) createMock(String name, Class<T> toMock)
d) createMock(String name, MockType type, Class<T> toMock)
View Answer

Answer: c
Explanation: The type parameter is the interface that the mock object should implement.
advertisement

10. createMock(String name, Class<T> toMock) throws _________________ exception.
a) IndexOutOfBounds
b) IllegalArgumentException
c) NullPointer
d) Arithmetic
View Answer

Answer: b
Explanation: This exception is thrown when the name is not a valid Java identifier.

Sanfoundry Global Education & Learning Series – JUnit.
To practice all areas of Junit, here is complete set of 1000+ Multiple Choice Questions and Answers.

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.