Loading

Quipoin Menu

Learn • Practice • Grow

spring / Factory Method in Spring
mcq
Direction: Choose the correct option

Q1.

What is a factory method in Spring?
A. A method that creates and returns a bean instance
B. A method that destroys beans
C. A method that configures beans
D. A method that processes annotations
Direction: Choose the correct option

Q2.

How do you declare a factory method in XML configuration?
A. Using factory-method attribute in <bean> tag
B. Using <factory-method> element
C. Using method attribute
D. Using factory-bean attribute
Direction: Choose the correct option

Q3.

What is a static factory method?
A. A static method that creates an instance of the class
B. A method that creates singleton beans
C. A method that creates prototype beans
D. None
Direction: Choose the correct option

Q4.

How do you configure a static factory method in Spring?
A. Specify class and factory-method
B. Specify factory-bean and factory-method
C. Use @Bean annotation
D. All of the above
Direction: Choose the correct option

Q5.

What is an instance factory method?
A. A non-static method of a factory bean that creates instances
B. A method that creates singleton beans
C. A method that returns the same instance
D. None
Direction: Choose the correct option

Q6.

How do you configure an instance factory method in Spring?
A. Use factory-bean and factory-method attributes
B. Use class and factory-method
C. Use @Bean on factory method
D. Both A and C
Direction: Choose the correct option

Q7.

Which annotation can be used to define a factory method in Java config?
A. @Bean
B. @Factory
C. @Component
D. @Service
Direction: Choose the correct option

Q8.

What is the FactoryBean interface?
A. A factory for creating complex beans
B. A bean that creates other beans
C. Both A and B
D. None
Direction: Choose the correct option

Q9.

Which method of FactoryBean returns the actual object?
A. getObject()
B. getBean()
C. createInstance()
D. newInstance()
Direction: Choose the correct option

Q10.

What is the advantage of using factory methods?
A. Encapsulates complex creation logic
B. Allows non-default constructors
C. Provides control over instantiation
D. All of the above