All questions
of 49Explain Inversion of Control (IoC) and Dependency Injection (DI).
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
IoC is a design principle where the control of object creation and management is transferred from the application code to an external container (Spring Container).
DI is the implementation of IoC where dependencies are injected into objects rather than objects creating their dependencies.
// Without DI - tight coupling
public class UserService {
private UserRepository userRepository = new UserRepository(); // Tight coupling
}
// With DI - loose coupling
public class UserService {
private UserRepository userRepository;
public UserService(UserRepository userRepository) {
this.userRepository = userRepository; // Dependency injected
}
}
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
The model's verdict: “”
The interactive diagram is below the answer - jump to diagram ↓
This answer is explained by a shared concept diagram - open →
What are the different types of Dependency Injection in Spring?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
Spring supports three types of DI:
- Constructor Injection: Dependencies injected through constructor
- Setter Injection: Dependencies injected through setter methods
- Field Injection: Dependencies injected directly into fields using @Autowired
// Constructor Injection (Recommended)
@Service
public class UserService {
private final UserRepository userRepository;
public UserService(UserRepository userRepository) {
this.userRepository = userRepository;
}
}
// Setter Injection
@Service
public class UserService {
private UserRepository userRepository;
@Autowired
public void setUserRepository(UserRepository userRepository) {
this.userRepository = userRepository;
}
}
// Field Injection
@Service
public class UserService {
@Autowired
private UserRepository userRepository;
}
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
The model's verdict: “”
The interactive diagram is below the answer - jump to diagram ↓
This answer is explained by a shared concept diagram - open →
What is the difference between @Component, @Service, @Repository, and @Controller?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
These are stereotype annotations for different layers:
- @Component: Generic stereotype for any Spring-managed component
- @Service: Indicates service layer components (business logic)
- @Repository: Indicates data access layer components (DAO)
- @Controller: Indicates presentation layer components (MVC controllers)
All are essentially @Component with semantic meaning. @Repository provides additional exception translation.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
The model's verdict: “”
The interactive diagram is below the answer - jump to diagram ↓
This answer is explained by a shared concept diagram - open →
What are the different ways to configure Spring applications?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
Spring supports three configuration approaches:
- XML-based configuration: Traditional XML files
- Annotation-based configuration: Using annotations like @Component, @Autowired
- Java-based configuration: Using @Configuration classes
// Java-based configuration
@Configuration
public class AppConfig {
@Bean
public UserService userService() {
return new UserService(userRepository());
}
@Bean
public UserRepository userRepository() {
return new UserRepository();
}
}
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
The model's verdict: “”
The interactive diagram is below the answer - jump to diagram ↓
This answer is explained by a shared concept diagram - open →
What is @Autowired and how does it work?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
@Autowired enables automatic dependency injection. Spring automatically injects matching beans by type. It can be used on:
- Constructors
- Setter methods
- Fields
- Method parameters
@Service
public class UserService {
@Autowired
private UserRepository userRepository; // Field injection
@Autowired
public UserService(UserRepository userRepository) { // Constructor injection
this.userRepository = userRepository;
}
}
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
The model's verdict: “”
The interactive diagram is below the answer - jump to diagram ↓
This answer is explained by a shared concept diagram - open →
What is Spring Boot and what are its advantages?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
Spring Boot is an opinionated framework that simplifies Spring application development by providing:
- Auto-configuration: Automatically configures Spring applications
- Starter dependencies: Pre-configured dependency sets
- Embedded servers: Tomcat, Jetty, Undertow embedded
- Production-ready features: Metrics, health checks, externalized configuration
- No XML configuration: Convention over configuration
- Standalone applications: JAR files with embedded servers
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
The model's verdict: “”
The interactive diagram is below the answer - jump to diagram ↓
This answer is explained by a shared concept diagram - open →
What are Spring Boot Starters?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
Starters are pre-configured dependency descriptors that include all necessary dependencies for specific functionality:
- spring-boot-starter-web: Web applications (Spring MVC, Tomcat)
- spring-boot-starter-data-jpa: JPA with Hibernate
- spring-boot-starter-security: Spring Security
- spring-boot-starter-test: Testing (JUnit, Mockito, TestNG)
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
The model's verdict: “”
The interactive diagram is below the answer - jump to diagram ↓
This answer is explained by a shared concept diagram - open →
What is @SpringBootApplication annotation?
What are the different types of request mapping annotations?
Explain @PathVariable, @RequestParam, and @RequestBody.
What is the difference between @Controller and @RestController?
What is Spring Data and what are its key features?
What is Spring Security and what are its core features?
Explain authentication vs authorization in Spring Security.
What is the Spring IoC Container and what are its types?
Explain the different bean scopes in Spring.
Explain the Spring Bean lifecycle.
What is the difference between @Autowired and @Resource?
What is Spring Boot Auto-configuration and how does it work?
Explain Spring Boot application properties and profiles.
What is Spring MVC and explain its architecture?
What is DispatcherServlet and what is its role?
Explain different types of controllers in Spring MVC.
How do you handle exceptions in Spring MVC?
Explain JpaRepository and its hierarchy.
How do query methods work in Spring Data JPA?
What is @Query annotation and when would you use it?
Explain pagination and sorting in Spring Data.
How do you configure Spring Security?
What are the different authentication methods in Spring Security?
What is Aspect-Oriented Programming (AOP) in Spring?
What are the different types of advice in Spring AOP?
How do you test Spring applications?
What is @SpringBootTest and its different modes?
Explain @MockBean vs @Mock in Spring Testing.
How do you test web controllers?
What are Spring Profiles and how are they used?
How do you create custom auto-configuration in Spring Boot?
Explain Spring Security's filter chain.
How do you implement JWT authentication in Spring Security?
What is the difference between JDK dynamic proxy and CGLIB proxy?
What is Spring WebFlux and how does it differ from Spring MVC?
Explain Spring's transaction management.
What is Spring Cloud and its key components?
Explain Spring's event handling mechanism.
What is @Conditional annotation and its use cases?
How does Spring handle circular dependencies?
What is Spring's ApplicationContext hierarchy?
Explain Spring's BeanPostProcessor and BeanFactoryPostProcessor.
This answer is part of Pro.
The full written answer, with the trade-offs and follow-ups an interviewer will probe.
No matches
Try a different filter or search term.
Spring Framework cheatsheet
Spring Framework Interview Cheat Sheet
- Summary01
- 1. Core Spring Concepts02
- 2. Spring Boot Essentials03
- 3. Spring MVC & REST04
- 4. Spring Data JPA05
- 5. Spring Security06
- 6. Aspect-Oriented Programming (AOP)07
- 7. Transaction Management08
- 8. Testing09
- 9. Caching10
- 10. Validation11
- 11. Scheduling12
- + 6 more inside
42 of 49 Spring Framework answers are gated.
Full answers, code samples, AI explanations - simpler, deeper, or as an interactive diagram. Cancel anytime.
- Full answers + code
- AI explain - simpler, deeper, or visualized
- 1,000 AI credits / month
- Cancel anytime
Change topic
Pick a different technology or stack. Your current topic stays put until you choose a new one.
MEAN
MongoDB, Express, Angular, Node.jsMERN
MongoDB, Express, React, Node.jsLAMP
Linux, Apache, MySQL, PHPRuby on Rails
Convention over ConfigurationJAM
JavaScript, APIs, and MarkupServerless on AWS
Serverless Architecture on AWSInterviewers also test these - they're common to every stack, whichever one you picked above.
Flutter Mobile
Flutter Cross-Platform Mobile DevelopmentInterviewers also test these - they're common to every stack, whichever one you picked above.
Spring Boot
Enterprise Java Development.NET
Microsoft EcosystemVue
Vue.js, Vite, TypeScript, Tailwind, Node.jsGo Backend
Golang, gRPC, PostgreSQL, Redis, RabbitMQFastAPI
Python, FastAPI, SQLAlchemy, PostgreSQLReact Native
React, TypeScript, Redux, FirebaseiOS Native
Swift, SwiftUI, UIKit, FirebaseAndroid Native
Java, Jetpack Compose, FirebaseWeb3 / Ethereum
Solidity, Ethereum, Hardhat, FoundryDevOps / Platform
Docker, Kubernetes, Terraform, CI/CDCore SWE Interview Prep
Data structures, algorithms, OS, concurrency, networking, gitInterviewers also test these - they're common to every stack, whichever one you picked above.
Interviewers also test these - they're common to every stack, whichever one you picked above.