0
0
Spring Bootframework~5 mins

Bean lifecycle overview in Spring Boot - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a Spring Bean?
A Spring Bean is an object that is managed by the Spring IoC container. It is created, configured, and managed by Spring during the application runtime.
Click to reveal answer
beginner
Name the main phases of the Spring Bean lifecycle.
The main phases are: Instantiation, Property Population (Dependency Injection), Initialization, Usage, and Destruction.
Click to reveal answer
intermediate
What happens during the Initialization phase of a Spring Bean?
During Initialization, Spring calls any custom initialization methods or lifecycle callbacks like @PostConstruct or afterPropertiesSet() to prepare the bean for use.
Click to reveal answer
intermediate
How can you customize the destruction of a Spring Bean?
You can customize destruction by implementing DisposableBean interface, using @PreDestroy annotation, or specifying a destroy-method in the bean configuration.
Click to reveal answer
beginner
What role does the Spring IoC container play in the Bean lifecycle?
The Spring IoC container controls the entire lifecycle of beans: creating, wiring dependencies, initializing, and destroying them when no longer needed.
Click to reveal answer
Which annotation is used to run code after a Spring Bean has been initialized?
A@PostConstruct
B@PreDestroy
C@Autowired
D@Bean
What is the first step in the Spring Bean lifecycle?
AInitialization
BDestruction
CInstantiation
DDependency Injection
Which interface can a Spring Bean implement to customize its destruction logic?
AInitializingBean
BDisposableBean
CBeanFactory
DApplicationContext
When does Spring perform dependency injection on a bean?
ADuring property population phase
BAfter destruction
CBefore instantiation
DAfter usage
Which annotation marks a method to be called before a bean is destroyed?
A@PostConstruct
B@Component
C@Autowired
D@PreDestroy
Explain the full lifecycle of a Spring Bean from creation to destruction.
Think about how Spring manages the bean step by step.
You got /5 concepts.
    How can you add custom behavior during the initialization and destruction phases of a Spring Bean?
    Consider both annotations and interfaces.
    You got /3 concepts.