Subjects

All subjects Django Java Python React Spring Boot JavaScript PHP
Sign Up Free
Spring Boot 10 questions

Dependency Injection & Bean Lifecycle

Master Spring IoC container. Learn bean definitions, autowiring, component scopes, circular dependencies, and lifecycle callbacks.

More Spring Boot
Interview questions 1–10 of 10
1

What is Dependency Injection and what problem does it solve?

Dependency Injection (DI) is a design pattern where an object's dependencies are supplied by an external sourc...

Read answer →
2

What is Inversion of Control (IoC) and how does the Spring IoC Container work?

Inversion of Control is the broader principle behind DI: control over object creation and wiring is inverted f...

Read answer →
3

What is the difference between Constructor Injection, Setter Injection, and Field Injection?

Constructor Injection supplies dependencies through a class constructor, making them final and guaranteeing th...

Read answer →
4

What are Spring Bean Scopes (singleton, prototype, request, session)?

Bean scope defines how many instances of a bean the container creates and how long they live. singleton (the d...

Read answer →
5

What is the Spring Bean Lifecycle, and what are its key phases?

The Spring Bean Lifecycle describes the sequence of steps the container performs to create, initialize, and ev...

Read answer →
6

What is the difference between @Component, @Service, @Repository, and @Controller?

All four are stereotype annotations built on top of @Component, so all are detected by component scanning and...

Read answer →
7

What is a Circular Dependency in Spring and how do you resolve it?

A circular dependency occurs when Bean A depends on Bean B, and Bean B depends back on Bean A (directly or thr...

Read answer →
8

What is @Qualifier and when do you need it?

When multiple beans of the same type exist in the container, @Autowired alone can't determine which one to inj...

Read answer →
9

What is @Bean vs @Component — when do you use each?

@Component (and its stereotypes like @Service) is a class-level annotation used when you own the source code —...

Read answer →
10

What is Autowiring by Type vs by Name, and what happens when Spring can't resolve a dependency?

By default, @Autowired resolves dependencies by type — Spring looks for a bean matching the field or parameter...

Read answer →