✅ 1️⃣ Core Spring Framework — Interview Questions
1️⃣ What is Spring Framework?
Spring is a lightweight Java framework used to build loosely coupled, testable, and maintainable applications using IoC, DI, and AOP.
2️⃣ What is Inversion of Control (IoC)?
IoC means Spring Framework controls object creation, not the developer.
Without IoC:
With IoC:
Spring creates and injects it automatically.
3️⃣ What is Dependency Injection (DI)?
DI provides required dependencies from outside instead of creating internally.
Example:
4️⃣ What is a Spring Bean?
A bean is an object managed by Spring Container.
5️⃣ Bean Scopes?
-
singleton (default)
-
prototype
-
request
-
session
Example:
6️⃣ What is @Component, @Service, @Repository, @Controller?
They are stereotype annotations:
-
@Component – generic bean
-
@Service – business logic
-
@Repository – database + exception translation
-
@Controller – MVC controller
7️⃣ What is @Autowired?
Used to inject dependencies automatically.
8️⃣ Difference between @Bean and @Component?
-
@Component → class level auto scanning
-
@Bean → method level manual bean creation
9️⃣ What is AOP in Spring?
Aspect Oriented Programming — handles cross-cutting concerns like logging, security.
🔟 What is @Transactional?
Handles transactions automatically.
1️⃣1️⃣ What is Spring MVC?
Framework for building web apps using MVC architecture.
1️⃣2️⃣ What is DispatcherServlet?
Front Controller in Spring MVC.
1️⃣3️⃣ What is ViewResolver?
Maps view names to actual pages.
1️⃣4️⃣ What are Profiles?
Used to define environments (dev/test/prod)
1️⃣5️⃣ What is Bean Lifecycle?
Bean creation → Dependency Injection → Initialization → Destruction
1️⃣6️⃣ What is @Lazy?
Delays bean creation until first use.
1️⃣7️⃣ What is @Primary?
Used when multiple beans exist for same type.
1️⃣8️⃣ What is @Qualifier?
Used to choose specific bean.
1️⃣9️⃣ What is ApplicationContext?
It is Spring’s IoC container.
2️⃣0️⃣ What is BeanFactory?
Basic container (ApplicationContext is advanced BeanFactory)
🚀 2️⃣ Spring Boot — Interview Questions
2️⃣1️⃣ What is Spring Boot?
Spring Boot simplifies Spring by providing:
✔ Auto Configuration
✔ Embedded Server
✔ Starter dependencies
2️⃣2️⃣ Difference — Spring vs Spring Boot?
| Spring | Spring Boot |
|---|---|
| Manual config | Auto Config |
| Needs server | Has embedded Tomcat |
| Many dependencies | Starters simplify |
2️⃣3️⃣ What is @SpringBootApplication?
Combination of:
-
@Configuration
-
@EnableAutoConfiguration
-
@ComponentScan
2️⃣4️⃣ How to create REST API?
2️⃣5️⃣ What are Starters?
Ready dependency packs like:
-
spring-boot-starter-web
-
spring-boot-starter-data-jpa
-
spring-boot-starter-test
2️⃣6️⃣ application.properties vs application.yml?
Both used for configuration.
2️⃣7️⃣ What is Spring Boot Actuator?
Provides health & monitoring endpoints.
2️⃣8️⃣ What is Auto Configuration?
Spring Boot configures beans automatically based on dependencies.
2️⃣9️⃣ How to Change Server Port?
3️⃣0️⃣ What is @RestController vs @Controller?
| Controller | RestController |
|---|---|
| returns view | returns JSON |
| uses @ResponseBody manually | built-in |
🗄 3️⃣ Spring Boot + Database / JPA
3️⃣1️⃣ How to configure DB?
3️⃣2️⃣ What is JPA Repository?
3️⃣3️⃣ Entity Example
3️⃣4️⃣ What is Hibernate?
ORM Framework used by JPA.
3️⃣5️⃣ What is @Entity?
Marks class as database table.
3️⃣6️⃣ What is @Id & @GeneratedValue?
Primary key + auto increment.
3️⃣7️⃣ Difference between save() and saveAll()?
save() — single record
saveAll() — multiple records
🔐 4️⃣ Spring Security
3️⃣8️⃣ What is Spring Security?
Framework for authentication + authorization.
3️⃣9️⃣ How to secure endpoint?
4️⃣0️⃣ What is OAuth2?
Authorization framework.
🧪 5️⃣ Spring Boot Testing
4️⃣1️⃣ How to Unit Test?
4️⃣2️⃣ MockMVC Example
4️⃣3️⃣ Test REST API
⚙ 6️⃣ Advanced Spring Questions
4️⃣4️⃣ What is Microservices?
Small independent services communicating via REST.
4️⃣5️⃣ What is REST?
Representational State Transfer — Web API standard.
4️⃣6️⃣ What is Feign Client?
Used for calling other microservices.
4️⃣7️⃣ What is Eureka?
Service registry.
4️⃣8️⃣ What is Circuit Breaker?
Prevents failures in distributed systems.
4️⃣9️⃣ What is @Value?
Reads values from properties.
5️⃣0️⃣ Difference between Monolithic & Microservice?
| Monolithic | Microservices |
|---|---|
| Single app | Multiple small services |
| Hard to scale | Easy to scale |
| Single failure kills app | Independent failure handling |
No comments:
Post a Comment