Explore topic-wise MCQs in Junit.

This section includes 9 Mcqs, each offering curated multiple-choice questions to sharpen your Junit knowledge and support exam preparation. Choose a topic below to get started.

1.

_____________ expects the last invocation once.

A. andVoid()
B. times(int min, int max)
C. once()
D. asStub()
Answer» D. asStub()
2.

_____________ records a call but returns nothing.

A. andVoid()
B. times(int min, int max)
C. once()
D. asStub()
Answer» B. times(int min, int max)
3.

_______________ sets a stub object implementing the same interface as the mock.

A. andAnswer(IAnswer<? extends T> answer)
B. andDelegateTo(Object delegateTo)
C. andStubAnswer(IAnswer<? extends T> answer)
D. andStubDelegateTo(Object delegateTo)
Answer» E.
4.

_____________ sets a stub object that will be used for the calculation of the answer for the expected invocation.

A. andAnswer(IAnswer<? extends T>answer)
B. andDelegateTo(Object delegateTo)
C. andStubAnswer(IAnswer<? extends T> answer)
D. andThrow(Throwable throwable)
Answer» D. andThrow(Throwable throwable)
5.

____________ expect the last invocation a specified number of times.

A. times(int count)
B. times(int min, int max)
C. once()
D. asStub()
Answer» B. times(int min, int max)
6.

_______________ expect the last invocation between min and max times.

A. times(int count)
B. times(int min, int max)
C. once()
D. asStub()
Answer» C. once()
7.

______________ sets stub behavior for the expected invocation.

A. andStubReturn(T value)
B. andThrow(Throwable throwable)
C. anyTimes()
D. asStub()
Answer» E.
8.

_____________ function expect the last invocation any times.

A. andStubReturn(T value)
B. andThrow(Throwable throwable)
C. anyTimes()
D. asStub()
Answer» D. asStub()
9.

The __________ interface allows setting expectations for an associated expected invocation.

A. IMocksControl
B. IExpectationSetters<T>
C. IExpectation<T>
D. Isetters<T>
Answer» C. IExpectation<T>