Java & Spring Boot Interview Questions and
Answers (3.5 Years Experience)
Core Java Interview Questions
Q: What is the difference between JDK, JRE, and JVM?
A: JDK (Java Development Kit) is for development, JRE (Java Runtime Environment) is for running
Java applications, and JVM (Java Virtual Machine) executes bytecode.
Q: Explain OOPS concepts in Java.
A: Four pillars: Encapsulation (data hiding), Inheritance (code reuse), Polymorphism (method
overloading/overriding), Abstraction (hiding implementation details).
Q: What are the differences between HashMap and Hashtable?
A: HashMap is non-synchronized, allows null keys/values, better for single-threaded apps.
Hashtable is synchronized, doesn’t allow null keys/values.
Q: What is the difference between final, finally, and finalize()?
A: final: keyword for constants, methods, and classes. finally: block in exception handling, always
executes. finalize(): method called by GC before object is destroyed.
Q: What are checked and unchecked exceptions?
A: Checked: compile-time (IOException, SQLException). Unchecked: runtime
(NullPointerException, ArithmeticException).
Spring Boot Interview Questions
Q: What is Spring Boot and how is it different from Spring?
A: Spring Boot simplifies Spring development with auto-configuration, embedded servers, and
opinionated starters.
Q: What are Spring Boot starters?
A: Predefined dependencies that simplify build configuration (e.g., spring-boot-starter-web).
Q: What is Spring Boot Auto-Configuration?
A: Automatically configures beans based on project dependencies.
Q: How does Spring Boot manage dependencies?
A: It uses a parent POM and dependency management for version control.
Q: What is the difference between @Component, @Service, @Repository, and @Controller?
A: @Component: generic bean, @Service: business logic, @Repository: persistence logic,
@Controller: web layer.
Advanced (Spring + Microservices) Questions
Q: What are Microservices and how does Spring Boot help build them?
A: Microservices are small, loosely coupled services. Spring Boot simplifies building microservices
with embedded servers, REST support, and integration with Spring Cloud.
Q: How do you secure REST APIs in Spring Boot?
A: Using Spring Security with JWT, OAuth2, or basic authentication.
Q: What is the difference between @RestController and @Controller?
A: @RestController = @Controller + @ResponseBody (sends JSON/XML responses). @Controller
is used for returning views.
Q: Explain Spring Boot Actuator.
A: Provides production-ready features like health checks, metrics, and monitoring.
Q: How to handle transactions in Spring Boot?
A: Using @Transactional annotation with propagation and isolation levels.