0% found this document useful (0 votes)
259 views8 pages

Spring

The document describes various aspects of the Spring framework. It includes multiple choice questions about Spring concepts like dependency injection, transactions, and the differences between the ApplicationContext and BeanFactory. It also asks about the default bean scope, Spring events, and which classes implement the TransactionStatus interface.

Uploaded by

Tarun Bhatia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
259 views8 pages

Spring

The document describes various aspects of the Spring framework. It includes multiple choice questions about Spring concepts like dependency injection, transactions, and the differences between the ApplicationContext and BeanFactory. It also asks about the default bean scope, Spring events, and which classes implement the TransactionStatus interface.

Uploaded by

Tarun Bhatia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 8

1. Which DataSource matches the following description ?

Configures a plain old J


DBC Driver via bean properties, and returns a new Connection every time. A. B.
C. D. E. SingleConnectionDataSource AbstractDataSource SmartDataSource Transacti
onAwareDataSourceProxy DriverManagerDataSource basic support is provided by Spri
ng's Data Access modules? handle boilerplate code. allow you to focus more on bu
siness. handle resources appropriately, such as database connections and transa
mantain the datasource protected by bloc ing concurrent access. translate specif
ic exceptions to a generic unchec ed exception hierarch B, C, A, D, E, C, D D B,
C E, A A
A. B. C. D. E.
A, B, E, C, D,
3. Which Transaction Manager implementation would be most appropriate to use fol
lowing scenario: Your Spring based application is to be deployed on JEE Applica
t ion Server. A. B. C. D. JpaTransactionManager HibernateTransactionManager JtaT
ransactionManager DataSourceTransactionManager
4. "Select the correct statements regarding initializing bean instances A:- Each
singleton bean is eagerly instanciated by default B:- Each bean is being instan
ciated lazy by default. C:- Beans are created in the right order with its depend
encies injected D:- Beans are created in the same order they are defined in the
xml file" A. B. C. D. A, B, C, C, B C D A
5. With local transactions, the application server is involved in transaction ma
nagement and it can help ensure correctness across multiple resources. A. B. TR
UE FALSE
6. Spring Framewor AOP implementation sugguests developers that "Always use the
most powerful form of advice that meets your requirements" A. B. TRUE FALSE
7. PlatformTransactionManager is an interface but can be used programmatically.

2. "What A:- They B:- They C:- They ctions. D:- They E:- They y."

A. B.
TRUE FALSE
8. "Consider the following code snippet: Employee scotty = (Employee)bf.getBean(
""scotty""); System.out.println(""scotty earns : "" + scotty.getSalary()); and b
ean configura tion: -<-alias name=""employee"" alias=""scotty"" />> -<-alias nam
e=""employeeOfTheMonth"" alias=""scotty"" /> -<-bean id=""employee"" class=""Emp
loyee""> -<-property name=""salary"" value=""2""/> -<-/bean> -<-bean id=""employ
eeOfTheMonth"" class=""Employee""> - <-property name=""salary"" value=""20000""/
> -<-/bean> Assuming that no compile errors exist and that bf refers to an insta
nce of BeanF actory that loaded the provided configuration. The output of the pr
ogram will be : 2 " A. B. TRUE FALSE
9. "The follwoing is true about Inversion of Control: A:- Inversion of Control o
ccurs when a main program has all the conrol and indiv idual components are as e
d to participate and execute when the main program deci des. B:- Inversion of Co
ntrol occurs when a main program receives the components that will execute at ru
ntime. C:- Inversion of Control occurs when a main program receives the componen
ts that will execute by configuration. D:- Dependency Injection is an Inversion
of Control technique that occurs when a main program receives the components tha
t will execute as parameters." A. B. C. D. A, B, C, D, B, C, D, A, C D, A A B
10. "Which of the following mechanisms can be used to register the new PropertyE
ditor (own CustomEditor) in Spring container? A:- property customEditors of bea
n factory post-processor called CustomEditorCon figurer B:- implement a Property
EditorRegistrar interface and set this implementation to CustomEditorConfigurer.
propertyEditorRegistrars property C:- registerCustomEditor() method from the App
licationContext D:- registerCustomEditor() method of the ConfigurableBeanFactory
interface, assu ming you have a BeanFactory reference" A. B. C. D. A, B, C, D,
B, C, D, A, C D A B
11. "a.xml -<-bean id=""beanA"" class=""beans.Inner"" /> b.xml -<-import resourc
e=""a.xml"" /> -<-bean id=""beanB"" class=""beans.Outer""> -<-property name=""be
anA"" ref=""bea nA"" /> -<-/bean> c.xml -<-import resource=""a.xml"" />

-<-bean id=""beanC"" class=""beans.Outer""> -<-property name=""beanA"" ref=""bea


nA"" /> -<-/bean> d.xml -<-import resource=""b.xml"" /> -<-import resource=""c.x
ml"" /> Bean factory is created from d.xml The question is, what is the default
bean factory behavior if beanA iis defined twice? (Once through b.xml->a.xml and
twice through c.xml->a.xml) " A. BeanDefinitionStoreException will be thrown B.
RuntimeException will be thrown C. Bean factory will alter bean ids internally
to eep them distinct and th en create two instances of class Inner D. Bean facto
ry will use the latest found bean definition and will start no rmally E. Bean fa
ctory will not detect duplicated definition of beanA 12. "Chec the correct defau
lt values for the @Transactional annotation A:- PROPAGATION_REQUIRED B:- The iso
lation level defaults to the default level of the underlying transact ion system
. C:- readOnly=""true"" D:- Only the Runtime Exceptions will trigger rollbac . E
:- The transaction timeout defaults to the default timeout of the underlying tr
ansaction system, or none if timeouts are not supported." A. B. C. D. E. A, B, E
, C, D, B, C, A, D, E, C, D D B E, A A, B
13. . The Spring's JDBC exception hierarchy is composed of unchec ed exceptions.
A. B. TRUE FALSE
14. "If we declare the following annotation (in its own file): @Service @Retenti
on(RetentionPolicy.RUNTIME) public @interface MyAnnotation { } Then the followin
g class: @MyAnnotation public class Foo { } will be a Spring bean if the appropr
iate context:component-scan element is added in the application context. " A. B.
15. A:B:C:A. TRUE FALSE "We can use @Autowired annotation with: methods constru
ctors properties" A, B, C

B. C.
B, C A, C
16. What is default bean scope in spring? A. B. C. D. E. prototype session singl
eton request global
17. "Which statements are true aboutApplicationContextandBeanFactory A:- Applicatio
nContext includes all functionality of the BeanFactory B:- Both ApplicationConte
xt, BeanFactory have convenient access to MessageSource C:- ApplicationContext l
oads beans eagerly, but BeanFactory lazily D:- Both ApplicationContext, BeanFact
ory have automatic registration to BeanPost Processor E:- Both ApplicationContex
t, BeanFactory are used for bean instantiation/wiring" A. B. C. D. E. 18. A:B:C:
D:A. B. C. D. A, B, A, C, D, B, C, C, D, E, C D E E A
"Select which of the following implement the TransactionStatus interface Abstrac
tTransactionStatus DefaultTransactionStatus SimpleTransactionStatus None of the
above" A, B, C, D, B, C C D, A A
19. Which method is defined in interface RowCallbac Handler? A. B. C. D. 20. A:B
:C:D:E:F:A. B. C. D. E. F. void void void void process(ResultSet rs) processResu
ltSet(ResultSet rs) processRow(ResultSet rs) processResult(ResultSet rs)
"Which of the following classes are built-in Spring Events. ContextRefreshedEven
t ContextClosedEvent ActionEvent ContextStoppedEvent ServletContextEvent Context
StartedEvent" A, B, E, A, D, A, B, C, A, B, E, B, C, D, E D, F F D, F A C

21. To access the methods defined in JdbcTemplate by using SimpleJdbcTemplate cl


ass instance, which of the following method can be used. A. B. C. D. getJdbcTem
plate() getJdbcOperations() getJdbcOperations(boolean useJdbcTemplate) None of t
he above
22. When Spring instantiates a map, it prefers JDK 1.4+ collection implementatio
ns (Lin edHashMap) to Commons Collections 3.x versions (org.apache.commons.coll
e ctions.map.Lin edMap), falling bac to JDK 1.3 collections (standard HashMap) a
s worst case. A. B. TRUE FALSE two exception classes: MyBaseBusinessException an
d My extends from MyBaseBusinessException. If rollbac -for and no-rollbac -for="
MySubBusinessException" are conf MySubBusinessException is thrown from transacti
onal c
B. 'rollbac -for' is applied and transaction will be rollbac ed. C. Exception is
thrown during application context initialization since conf iguration is ambigu
ous. D. None of the above 24. To register custom application event listener it i
s enough to write a class implementingApplicationListenerinterface and simply incl
ude that class in applicat ion context by usingelement (provided you're using an
Application Context rather than a simple Bean Factory). A. B. TRUE FALSE
25. Which Transaction Manager implementation would you choose in following scena
rio:You have a single datasource to deal with in your Spring Based application
a nd you need transaction management. A. B. C. D. JpaTransactionManager Hibernat
eTransactionManager JtaTransactionManager DataSourceTransactionManager
26. xxxAwaremethods of the bean are invo ed after the setter injection. A. B. 27.
A:B:C:s a D:E:F:TRUE FALSE "The following is true about PlatformTransactionMana
ger: It is an interface. It is a class. It has a method getTransaction(Transacti
onDefinition definition) that return TransactionStatus. It has a method commit(T
ransactionStatus status) that returns void. It has a method rollbac (Transaction
Status status) that returns void. All its methods throw TransactionException."

A.
'no-rollbac -for rule' is applied and transaction will not rollbac .

23. Imagine that there are SubBusinessException which ="MyBaseBusinessException"


igured what happens when a ontext?

A. B. C. D. E. F.
A, B, E, C, D, D,
B, C, A, D, E, E,
C, D, F E A, B,
D E F, C F, C
28. "Consider the following valid declarations: -<-bean id=""bar"" class=""x.y.B
ar""/> -<-bean id=""baz"" class=""x.y.Baz""/> -<-bean id=""foo"" class=""x.y.Foo
""> -<-constructor-arg ref=""bar""/> -<-constructor-arg ref=""baz""/> -<-constru
ctor-arg value=""example""/> -<-/bean> Which of the following declarations using
c-namespace are valid? A:- -<-bean id=""foo"" class=""x.y.Foo"" c:bar=""bar"" c
:baz=""baz"" c:email=""e xample@example.com"" /> B:- -<-bean id=""foo"" class=""
x.y.Foo"" c:bar-ref=""bar"" c:baz-ref=""baz"" c:e mail=""example@example.com"" /
> C:- -<-bean id=""foo"" class=""x.y.Foo"" c:_0-ref=""bar"" c:_1-ref=""baz"" c:_
2= ""example@example.com"" />" A. B. C. A, B B, C A, C
29. Does JdbcTemplate has a delete operation in API to delete rows from a table?
A. B. YES NO
30. "Spring eases the data access process by ma ing use of two distinct classes:
templates and callbac s. Which of the following classes are not shipped with Sp
ring? A:- JdbcTemplate B:- HibernateTemplate C:- JpaTemplate D:- OracleTemplate
E:- NamedParameterJdbcTemplate F:- PLSqlTemplate" A. B. C. D. E. F. A, B, E, C,
D, D, B, C, A, D E, F C, D D F A

You might also like