Explore topic-wise MCQs in Spring.

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

1.

Which configuration can be used for Dependency Injection?

A. XML Configuration
B. Annotation Configuration
C. Java Based Configuration
D. All of the mentioned
Answer» E.
2.

Which annotation is used as a substitute of initialization method?a) @PostConstructb) @PreDestroyc) None of the mentionedd) All of the mentioned 14.Which annotation is used as a substitute of destroy method?

A. @PostConstructb) @PreDestroyc) None of the mentionedd) All of the mentioned 14.Which annotation is used as a substitute of destroy method?a) @PostConstruct
B. @PreDestroyc) None of the mentionedd) All of the mentioned 14.Which annotation is used as a substitute of destroy method?a) @PostConstructb) @PreDestroy
C. None of the mentionedd) All of the mentioned 14.Which annotation is used as a substitute of destroy method?a) @PostConstructb) @PreDestroyc) None of the mentioned
D. All of the mentioned 14.Which annotation is used as a substitute of destroy method?a) @PostConstructb) @PreDestroyc) None of the mentionedd) All of the mentionedView Answer
Answer» B. @PreDestroyc) None of the mentionedd) All of the mentioned 14.Which annotation is used as a substitute of destroy method?a) @PostConstructb) @PreDestroy
3.

Alternate way of destruction method is:-

A. init-method attribute
B. afterPropertiesSet
C. destroy-method attribute
D. none of the mentioned
Answer» D. none of the mentioned
4.

Alternate way of initialization method is:-

A. init-method attribute
B. afterPropertiesSet
C. destroy-method attribute
D. none of the mentioned
Answer» B. afterPropertiesSet
5.

Which interface is used to perform destruction of beans?

A. InitializingBean
B. Disposablebean
C. None of the mentioned
D. All of the mentioned
Answer» C. None of the mentioned
6.

Which interface is used to perform initialization of beans?

A. InitializingBean
B. Disposablebean
C. None of the mentioned
D. All of the mentioned
Answer» B. Disposablebean
7.

In above question if scope of shoppingCart named bean is prototype, then what will be the output?What will be the output?

A. Shopping cart 1 contains (AAA 2.5, CD-RW 1.5) Shopping cart 2 contains (AAA 2.5, CD-RW 1.5, DVD-RW 3.0)
B. Shopping cart 1 contains (AAA 2.5, CD-RW 1.5) Shopping cart 2 contains (DVD-RW 3.0)
C. BeanCreationException
D. None of the mentioned
Answer» C. BeanCreationException
8.

What will be the output?

A. Shopping cart 1 contains (AAA 2.5, CD-RW 1.5) Shopping cart 2 contains (AAA 2.5, CD-RW 1.5, DVD-RW 3.0)
B. Shopping cart 1 contains (AAA 2.5, CD-RW 1.5) Shopping cart 2 contains (DVD-RW 3.0)
C. BeanCreationException
D. None of the mentionedView Answer
Answer» B. Shopping cart 1 contains (AAA 2.5, CD-RW 1.5) Shopping cart 2 contains (DVD-RW 3.0)
9.

Which of the following are considered valid beans?

A. Singleton
B. Prototype
C. All of the mentioned
D. None of the mentioned
Answer» D. None of the mentioned
10.

Session Creates a single bean instance per HTTP request, only valid in the context of a web application?

A. True
B. False
Answer» C.
11.

Which scope creates a new bean instance each time when requested?

A. Singleton
B. Prototype
C. Session
D. Request
Answer» C. Session
12.

Which one is the default scope of the beans?

A. Prototype
B. Session
C. Request
D. Singleton
Answer» E.
13.

Which attribute is used to set the scope of the bean?

A. setScope
B. scope
C. getScope
D. none of the mentioned
Answer» C. getScope
14.

A bean can be requested by:-

A. getBean method
B. reference from another bean using autowiring, property etc
C. all of the mentioned
D. none of the mentioned
Answer» D. none of the mentioned
15.

IN_ABOVE_QUESTION_IF_SCOPE_OF_SHOPPINGCART_NAMED_BEAN_IS_PROTOTYPE,_THEN_WHAT_WILL_BE_THE_OUTPUT??$

A.
B. Shopping cart 1 contains (AAA 2.5, CD-RW 1.5)
C.
Answer» B. Shopping cart 1 contains (AAA 2.5, CD-RW 1.5)
16.

Which interface is used to perform destruction of beans?$

A. InitializingBean
B. Disposablebean
C. None of the mentioned
D. All of the mentioned
Answer» B. Disposablebean
17.

Which_interface_is_used_to_perform_initialization_of_beans?$

A. InitializingBean
B. Disposablebean
C. None of the mentioned
D. All of the mentioned
Answer» C. None of the mentioned
18.

Alternate_way_of_initialization_method_is:-

A. init-method attribute
B. afterPropertiesSet
C. destroy-method attribute
D. none of the mentioned
Answer» D. none of the mentioned
19.

5, CD-RW 1.5?

A.
B. Shopping cart 1 contains (AAA 2.5, CD-RW 1.5)
C.
D. BeanCreationException
Answer» C.