Loading

Quipoin Menu

Learn • Practice • Grow

spring / Spring Beans & Lifecycle
mcq
Direction: Choose the correct option

Q1.

What is a Spring bean?
A. An object that is instantiated, assembled, and managed by the Spring IoC container
B. A Java class with special annotations
C. A configuration file
D. A database entity
Direction: Choose the correct option

Q2.

Which interface can be implemented to perform custom initialization after bean properties are set?
A. InitializingBean
B. BeanPostProcessor
C. DisposableBean
D. ApplicationContextAware
Direction: Choose the correct option

Q3.

What is the purpose of BeanPostProcessor?
A. To intercept bean creation and provide custom processing before and after initialization
B. To define bean scope
C. To handle dependencies
D. To configure profiles
Direction: Choose the correct option

Q4.

Which annotation can be used for custom initialization method?
A. @PostConstruct
B. @PreDestroy
C. @Init
D. @Bean(initMethod='...')
Direction: Choose the correct option

Q5.

What is the correct order of bean lifecycle?
A. Instantiation → Populate properties → BeanPostProcessor postProcessBeforeInitialization → Initialization callbacks → BeanPostProcessor postProcessAfterInitialization
B. Instantiation → Initialization → Populate properties
C. Populate properties → Instantiation → Initialization
D. Initialization → Instantiation → Populate properties
Direction: Choose the correct option

Q6.

Which method is called when a bean is being destroyed?
A. destroy()
B. close()
C. shutdown()
D. @PreDestroy annotated method
Direction: Choose the correct option

Q7.

How can you define a bean in Spring configuration?
A. Using <bean> tag in XML
B. Using @Bean annotation in Java config
C. Using @Component with component scanning
D. All of the above
Direction: Choose the correct option

Q8.

What is the purpose of @Lazy annotation?
A. To delay bean initialization until first request
B. To destroy bean lazily
C. To make bean optional
D. To skip bean creation
Direction: Choose the correct option

Q9.

Which interface provides access to application context from a bean?
A. ApplicationContextAware
B. BeanFactoryAware
C. ResourceLoaderAware
D. All of the above
Direction: Choose the correct option

Q10.

What happens to singleton beans when the container is closed?
A. They are destroyed and cleanup methods are called
B. They remain in memory
C. They are serialized
D. Nothing