Java & Spring Boot Interview
Curated 20+ questions covering Java OOP, JVM garbage collection, Spring IoC/DI, Spring Boot configurations, and JPA/Hibernate.
Difficulty Filters
Tools & Options
What are the core principles of Object-Oriented Programming (OOP)?
The four core principles of OOP are:
1. Encapsulation: Hiding data fields and exposing them through getter/setter methods.
2. Inheritance: Creating parent-child relationships between classes to reuse code.
3. Polymorphism: Allowing methods to take different forms (Method Overloading and Method Overriding).
4. Abstraction: Hiding internal implementation details using interfaces and abstract classes.
What is Spring Boot, and how does it differ from the Spring Framework?
Spring is a Java application framework providing dependency injection and core components. Spring Boot is an extension of Spring that makes it easy to create stand-alone, production-ready applications. It simplifies development by providing:
1. Auto-configuration: Automatically configures beans based on classpath dependencies.
2. Starters: Pre-packaged dependency bundles.
3. Embedded Server: Built-in Tomcat/Jetty, avoiding standalone WAR deployments.
Explain Dependency Injection (DI) and Inversion of Control (IoC).
Inversion of Control (IoC) is a design principle where the control of object creation and lifecycle is transferred from the program code to a container. Dependency Injection (DI) is a specific implementation of IoC where dependencies are dynamically injected into a class (via Constructor, Setter, or Field) by the Spring IoC container.
@Component
public class Car {
private Engine engine;
// Constructor injection (Preferred)
@Autowired
public Car(Engine engine) {
this.engine = engine;
}
}What are the different ways to inject dependencies in Spring?
What is Spring Boot Auto-configuration, and how does it work?
What is Spring Boot Actuator?
What is the difference between `@Component`, `@Service`, and `@Repository` annotations?
Explain Spring Bean Scopes.
What is Hibernate, and how does it relate to JPA?
What is the difference between `@RestController` and `@Controller`?
What is the Spring Boot Starter?
How do you handle exceptions globally in Spring Boot?
Explain Lazy Loading vs Eager Loading in Hibernate/JPA.
What is the N+1 select problem in Hibernate, and how do you resolve it?
Explain the garbage collection process in Java.
What is the difference between `HashMap` and `ConcurrentHashMap` in Java?
Explain Spring AOP (Aspect-Oriented Programming).
What is the use of the `@Transactional` annotation?
What is the Spring Cloud, and when is it used?
Explain the Java 8 Stream API.
Technical Interview Mastery Blueprint
Proven methodologies and frameworks to succeed in technical and architecture rounds.
1. The Engineering STAR Technique
When responding to architectural or situational questions, structure your answer using Situation, Technical Constraint, Action, and Measurable Result. Rather than jumping straight to syntax, articulate the business problem, why certain patterns (e.g. caching, queuing, immutability) were selected over alternatives, and what latency or throughput improvements were achieved.
2. Defending Architectural Trade-Offs
Senior interviewers evaluate how you weigh trade-offs. Always explain why you chose an approach: e.g., memory overhead vs CPU cycle speed, consistency vs availability (CAP theorem), or normalized schemas vs denormalized fast reads. Stating the drawbacks of your own proposal demonstrates maturity and production experience.
3. Clean Code & Edge-Case Proactivity
In live-coding rounds, communicate your thinking aloud before typing. State edge cases explicitly: null or undefined inputs, extreme boundary values, concurrency races, and network timeouts. Writing modular, well-named functions with deterministic unit tests separates junior candidates from staff-level engineers.
4. Antipatterns to Avoid
Avoid reciting memorized definitions without practical context. Never dismiss non-functional requirements such as security (CSRF, injection, token rotation), observability (logging, metrics), and accessibility (ARIA, semantic standards). Always ask clarifying scope questions before writing complex implementations.
Explore Related Tools
Hand-picked utilities and calculators related to this tool.
