Spring Boot Interview Question

What is a Spring bean?

Updated 2026-08-16 · Beginner friendly
Quick answer

A Spring bean is an object that the Spring container creates, configures, and manages for you. You mark a class as a bean with annotations like Component, Service, or Bean, and Spring keeps it in its application context ready to inject where needed. By default beans are singletons, meaning one shared instance per container.

Key takeaways
  • A Spring bean is an object that the Spring container creates, wires, and manages.
  • Beans are usually defined by annotations like Component or by methods marked Bean.
  • The container handles a bean's full lifecycle, from creation to destruction.

How a bean is created

@Component
class EmailService { }

// or from a configuration method
@Bean
EmailService emailService() { return new EmailService(); }

Common bean scopes

In the interview

Be ready for the scope question. Say the default is singleton, one shared instance, and use prototype when you need a fresh object each time. Knowing that singleton is the default catches a common misconception.

Frequently asked questions

What is the default scope of a bean?

The default scope is singleton, meaning the container creates one shared instance per application context and reuses it everywhere it is injected.

How does a class become a bean?

By annotating it with a stereotype like Component, Service, or Repository and letting component scanning find it, or by defining it with a Bean method.

Want the full Spring Boot guide?

Read every Spring Boot concept with notes, diagrams, and code in one place. Track your progress as you go.

Open the Spring Boot guide All Spring Boot questions