0
0
Spring Bootframework~5 mins

Bean concept in Spring in Spring Boot - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a Bean in Spring Framework?
A Bean is an object that is managed by the Spring container. It is created, configured, and assembled by Spring to be used in the application.
Click to reveal answer
beginner
How does Spring know which classes to manage as Beans?
Spring uses annotations like @Component, @Service, @Repository, or XML configuration to identify and manage classes as Beans.
Click to reveal answer
intermediate
What is the default scope of a Bean in Spring?
The default scope is 'singleton', meaning Spring creates only one instance of the Bean per container.
Click to reveal answer
intermediate
Explain the difference between singleton and prototype Bean scopes.
Singleton scope creates one shared instance for the whole application. Prototype scope creates a new instance every time the Bean is requested.
Click to reveal answer
beginner
What is Dependency Injection in the context of Spring Beans?
Dependency Injection is when Spring automatically provides the required Beans to other Beans, so they don’t have to create or find them manually.
Click to reveal answer
Which annotation is commonly used to mark a class as a Spring Bean?
A@Component
B@Bean
C@Autowired
D@ServiceProvider
What is the default scope of a Spring Bean?
Aprototype
Bsingleton
Crequest
Dsession
Which of the following is NOT a valid Spring Bean scope?
Atransient
Bprototype
Csingleton
Drequest
What does Dependency Injection help with in Spring?
AWriting SQL queries
BManually creating objects
CAutomatically providing required Beans
DManaging database connections
Which annotation is used to inject a Bean into another Bean?
A@Component
B@Repository
C@Service
D@Autowired
Describe what a Spring Bean is and how Spring manages it.
Think about how Spring controls the objects your app uses.
You got /3 concepts.
    Explain the difference between singleton and prototype Bean scopes in Spring.
    Consider how many copies of the Bean exist in each scope.
    You got /3 concepts.