Spring
Spring
Spring
1. What is Spring?
A) Spring is framework which has in-built design patterns and technologies provided
supports for faster application development (RAD=Rapid Application Development).
1|Page
RAGHU SIR (Sathya Technologies, Ameerpet, Hyd)
A) Creating Objects, Providing data, linking one object with another object, calling life cycle
methods finally destroy the objects.
8. What are different scopes provided by Spring container and explain LMI?
a) singleton: one Object per one <bean>(default scope)
b) prototype: Every time new object when requested.
c) request: New object for every HTTP request.
d) session: One object for one HTTP session.
e) global session: works for portlet only
LMI = When Parent is singleton and child is prototype then container will not look for new
child object to inject with parent.
10. What is the difference between constructor injection and setter injection?
Setter Injection Constructor Injection
We set pass few values(Parital injection) All values must be passed
Provides data using set method Provide data using param constructor
Use only if few values need to be set Use only if all values need to be set
Order not required Order is followed
Use <property> tag Use <constructor-arg> tag
It will create a new instance if any It will not create new instance if any
modification is done. modification is done
2|Page
RAGHU SIR (Sathya Technologies, Ameerpet, Hyd)
@Bean annotation must be applied over method. By default method name behaves as
object name.
14. What are Stand Alone Collections ? What are different ways of creating them?
A) An independent and Re-usable collection is called as Stand Alone Collection (SAC).
Using XML with util schema: <util:collectionname ..> </util:collectionname>
Using Java : @Bean over method returns Any Collection Type.
18. What are different ways of providing primitive data using XML?
3|Page
RAGHU SIR (Sathya Technologies, Ameerpet, Hyd)
19. What are different ways of writing reference type (link) using XML?
A) ref as tag (<ref bean="childbeanname"/>)
Ref as attribute (<property name=" " ref="childobjname"/>)
P-schema/p-namespace (<bean .. P:variablename-ref="childobjname"..)
Inner Bean (Child bean inside Parent Bean)
20. What are different ways of providing entry for a map using XML?
A) 4 ways.
a) Key and Values as Tag , (<entry> <key>..</key> <value>..</value> </entry>)
b) Key and value as attributes(<entry key="" value="" />)
c) Key as tag and value as attribute(<entry value=""> <key>..</key> </entry>),
d) Key as attribute and value as tag (<entry key=""> <value>..</value> </entry>)
4|Page
RAGHU SIR (Sathya Technologies, Ameerpet, Hyd)
28. Write XML, Java and Annotation Configuration using all types of Dependencies.
29. Write Example for lifecycle methods
30. Write Example for Inner Bean using XML Configuration
31. Write Example for sacs using XML and Java Configs.
32. Write Example for Loading and Reading Properties file in 3 configurations.
33. Writer Example for Scopes and LMI Solution
34. Explain Circular Dependency using XML with steps.
35. Write Example for Map configuration in XML using different <entry> styles.
36. What are the rules to write Spring Bean?
37. Is Spring Bean Thread Safe?
A)No by default, because scope is singleton. To make it thread safe make it is prototype or
session.
38. Can we define multiple configuration file? How to handle them ?
A) Yes. But Import one into another finally.
Using XML <import resource="__.xml"/>
Using Java @Import(___.class)
5|Page