Introduction To Spring And Advanced Spring(Engineering > Computer Science And Engineering > Spring ) Questions and Answers
Question 1. Which method is used to gracefully shutdown all the bean processes after closing the spring container?
shutdownHook
destory method
none of the mentioned
all of the mentioned
Explanation:-
Answer: Option A. -> shutdownHook
ShutdownHook method gracefully shuts down each bean process before closing the container.
Question 2. What are the ways to create custom Property Editors?
implement PropertyEditor interface
extend PropertyEditorSupport Class
none of the mentioned
all of the mentioned
Explanation:-
Answer: Option D. -> all of the mentioned
You can write custom property editors by implementing the java.beans.PropertyEditor interface or extending the convenient support class java.beans.PropertyEditorSupport.
Question 3. Which one is the default scope of the beans?
Prototype
Session
Request
Singleton
Explanation:-
Answer: Option D. -> Singleton
This unique bean instance will be returned for all subsequent getBean() calls and bean references.
Question 4. Declaring bean form object properties can be done using:-
PropertyPathFactoryBean
util:constant
None of the mentioned
All of the mentioned
Explanation:-
Answer: Option A. -> PropertyPathFactoryBean
To declare a bean from an object property or a property path, you can make use of either the built-in factory bean PropertyPathFactoryBean or the util:property-path tag in Spring 2.x.
Question 5. Which attribute is used to specify classname of the bean?
name
id
class
constructor-args
Explanation:-
Answer: Option C. -> class
Class attribute is mandatory and denotes the class used to create bean.
Question 6. Which package is used for periodic work
java.lang.Thread
java.util.TimerTask
java.util.Timer
java.util.concurrent
Explanation:-
Answer: Option B. -> java.util.TimerTask
Java 1.3 saw the introduction of java.util.TimerTask to support doing some sort of work periodically.
Question 7. Which attribute is used to set the scope of the bean?
setScope
scope
getScope
none of the mentioned
Explanation:-
Answer: Option B. -> scope
Scope attribute defines the scope of a bean.
Question 8. Method used to process bean before initialization callback
scope
postProcessAfterInitialization()
postProcessBeforeInitialization()
it's own constructor
Explanation:-
Answer: Option C. -> postProcessBeforeInitialization()
You can process every bean before initialization callback method by implementing the postProcessBeforeInitialization() and methods.
Question 9. Which tag is also allowed by static field?
util:constant
list
set
constructor-args
Explanation:-
Answer: Option A. -> util:constant
Spring 2 and later allow you to declare a bean from a static field by using the util:constant tag.
Question 10. Which attribute is used to specify classname of the bean?
name
id
class
constructor-args
Explanation:-
Answer: Option C. -> class
Class attribute is mandatory and denotes the class used to create bean.