Interview questions
Question 29 of 254
FreeWhat is the lifecycle of a Spring bean, from instantiation to destruction?
Bean Lifecycle & Scopes
The container instantiates the bean (constructor call), injects dependencies (constructor/setter/field), calls Aware interface callbacks if implemented (e.g., BeanNameAware), runs BeanPostProcessor.postProcessBeforeInitialization, calls initialization callbacks (@PostConstruct, then InitializingBean.afterPropertiesSet(), then a custom init-method), runs BeanPostProcessor.postProcessAfterInitialization, and the bean is now ready for use — until container shutdown triggers @PreDestroy, DisposableBean.destroy(), and any custom destroy-method, in that order.
Intermediate5 min

