Explore topic-wise MCQs in Spring.

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

1.

An Object which usually knows how its methods are expected to be called:-

A. stub
B. mock
C. test
D. none of the mentioned
Answer» C. test
2.

An object that simulates a dependent object:-

A. stub
B. mock
C. test
D. none of the mentioned
Answer» B. mock
3.

Test data sets are provided by data providers, which are methods with the:-

A. @DataProvider
B. @Autowire
C. @JTest
D. None of the mentioned
Answer» B. @Autowire
4.

Attribute which specifies the exception type:-

A. after
B. expected
C. before
D. test
Answer» C. before
5.

This encapsulates the context of a test’s execution:-

A. Test context
B. Test context manager
C. Test context listener
D. Test execution listener
Answer» B. Test context manager
6.

TEST_DATA_SETS_ARE_PROVIDED_BY_DATA_PROVIDERS,_WHICH_ARE_METHODS_WITH_THE:-?$

A. @DataProvider
B. @Autowire
C. @JTest
D. None of the mentioned
Answer» B. @Autowire
7.

An Object which usually knows how its methods are expected to be called:-$

A. stub
B. mock
C. test
D. none of the mentioned
Answer» C. test
8.

An object that simulates a dependent object:-$

A. stub
B. mock
C. test
D. none of the mentioned
Answer» B. mock
9.

Spring supports web controller testing by providing Servlet API:-

A. MockHttpServletRequest
B. MockHttpServletResponse
C. MockHttpSession
D. All of the mentioned
Answer» E.
10.

Test used to test several units in combination as a whole.

A. Integration tests
B. JUnit4
C. TestNG5
D. All of the mentioned
Answer» B. JUnit4
11.

Libraries that can help create mock objects:-

A. EasyMock
B. jMock
C. All of the mentioned
D. None of the mentioned
Answer» D. None of the mentioned
12.

Attribute which specifies the exception type:?

A. after
B. expected
C. before
D. test
Answer» C. before
13.

The static assert methods is declared in the:-

A. org.junit.Assert
B. org.junit.*
C. all of the mentioned
D. none of the mentioned
Answer» D. none of the mentioned
14.

Method to perform cleanup tasks:-

A. finalize
B. tearDown
C. all of the mentioned
D. none of the mentioned
Answer» D. none of the mentioned
15.

Usually, a test and its target class are located in the same package, but the source files of tests are stored in a separate directory.

A. True
B. False
Answer» B. False
16.

JUnit 4 allows you to annotate your test methods with:-

A. @Test
B. @Autowire
C. @JTest
D. None of the mentioned
Answer» B. @Autowire
17.

Spring provides convenient TestContext support classes for:-

A. JUnit3
B. JUnit4
C. TestNG5
D. All of the mentioned
Answer» E.
18.

This defines a listener interface; by implementing this, you can listen to test execution events.

A. Test context
B. Test context manager
C. Test context listener
D. Test execution listener
Answer» E.
19.

This manages a test context for a test and triggers test execution listeners:-

A. Test context
B. Test context manager
C. Test context listener
D. Test execution listener
Answer» C. Test context listener
20.

This encapsulates the context of a test’s execution:-

A. Test context
B. Test context manager
C. Test context listener
D. Test execution listener
Answer» B. Test context manager