Test Series - spring

Test Number 1/20

Q: Beans can be created by which of the following properties?
A. Scope
B. Property
C. Class
D. It’s own constructor
Solution: Class’s constructor can create bean.
Q: Which attribute is used to specify class name of the bean?
A. name
B. id
C. class
D. constructor-args
Solution: Class attribute is mandatory and denotes the class used to create bean.
Q: Which of the following method can be used to used to instantiate a method?
A. static factory method
B. default-init method
C. destroy method
D. lazy-init method
Solution: Class attribute is used to specify the name of the class that contains the static factory method.
Q: Which attribute is used to specify static factory-method?
A. factory-method
B. default-init method
C. destroy method
D. lazy-init method
Solution: factory-method attribute denotes the name of actual method of the class.
Q: Purpose of Static Factory Method?
A. Static method to create an object
B. Initialize bean
C. All of the mentioned
D. None of the mentioned
Solution: Instantiate a bean using static method.
Q: Exception thrown by factory method?
A. IllegalArgumentException
B. IndexOutofBoundException
C. ClassPathNotFoundException
D. BeanCreationException
Solution: Spring generates the above mentioned exception, in case something’s wrong.
Q: Beans can be created by which of the following properties?
A. Static factory-method
B. Instance Factory-Method
C. All of the mentioned
D. None of the mentioned
Solution: Instantiate a bean via static and instance Factory methods.
Q: Instance Factory method main purpose is to encapsulate the object-creation process in a method of another object instance.
A. True
B. False
C. 1
D. 0
Solution: The client who requests an object can simply make a call to this method without knowing about the creation detail.
Q: One factory class can also hold more than one factory method True/False?
A. True
B. False
C. 1
D. 0
Solution: A single instantiated bean can have more than one methods.
Q: Which Attribute is used to specify the bean declared?
A. factory-bean
B. scope
C. getBean
D. declareBean
Solution: To declare a bean created by an instance factory method, you specify the bean hosting the factory method in the factory-bean attribute.

You Have Score    /10