Test Series - spring

Test Number 2/20

Q: Declaring Beans using:-
A. Static field
B. Object Properties
C. All of the mentioned
D. None of the mentioned
Solution: Beans can be declared from static fields as well as Object properties.
Q: Ways to declare bean from a static field?
A. FieldRetrievingFactoryBean
B. util:contant
C. All of the mentioned
D. None of the mentioned
Solution: To declare a bean from a static field, you can make use of either the built-in factory bean FieldRetrievingFactoryBean, or the util:constant tag in Spring 2.x.
Q: Which tag is also allowed by static field?
A. util:constant
B. list
C. set
D. constructor-args
Solution: Spring 2 and later allow you to declare a bean from a static field by using the util:constant tag.
Q: Declaring bean form object properties can be done using:-
A. PropertyPathFactoryBean
B. util:constant
C. None of the mentioned
D. All of the mentioned
Solution: 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.
Q: PropertyPathFactoryBean declares a bean from an:-
A. Object Property
B. Property Path
C. All of the mentioned
D. None of the mentioned
Solution: The factory bean PropertyPathFactoryBean can be used to declare a bean from an object property or a property path.
Q: Alternate way of PropertyPathFactoryBean to declare a bean.
A. util:property-path tag
B. util:constant tag
C. None of the mentioned
D. All of the mentioned
Solution: Compared to using PropertyPathFactoryBean, it is a simpler way of declaring beans from properties.
Q: The Spring Expression Language can be accessed by:-
A. XML configuration
B. Annotations
C. None of the mentioned
D. All of the mentioned
Solution: The expression language is available via XML or annotations.
Q: We can combine target Object and propertyPath properties as bean name/id of PropertyPathFactoryBean.
A. True
B. False
C. 1
D. 0
Solution: In addition to specifying the targetObject and propertyPath properties explicitly, you can combine them as the bean name of PropertyPathFactoryBean. The downside is that your bean name may get rather long and verbose.
Q: The propertyPath property of PropertyPathFactoryBean can accept only a single property name.
A. True
B. False
C. 0
D. 1
Solution: The propertyPath property of PropertyPathFactoryBean can accept not only a single property name but also a property path with dots as the separators.
Q: Inner Bean can be retrieved by it’s name.
A. True
B. False
C. 0
D. 1
Solution: Since inner beans are local to another bean, so can’t be accessed globally.

You Have Score    /10