50 Java Interview Questions
Core Java & OOPs
1. Explain the main principles of OOP (Object-Oriented Programming).
2. Differentiate between == and .equals() in Java.
3. Explain the difference between ArrayList and LinkedList.
4. What is the purpose of the final keyword in Java?
5. Explain checked and unchecked exceptions in Java.
6. What is a Singleton Class, and how do you implement it?
7. Explain the concept of method overloading and method overriding.
8. What is HashMap and ConcurrentHashMap? When would you use one over the
other?
9. What is the purpose of the super keyword?
10.What is a marker interface? Give examples.
11. How does Garbage Collection work in Java?
12.Explain the try-catch-finally block.
13.What is the this keyword in Java?
14.What are inner classes in Java? Explain different types.
15.What is the difference between interface and abstract class?
Java 8 Features
16.What are Lambda Expressions in Java 8, and why are they useful?
17.What is a Functional Interface? Give an example.
18.Explain the Java Stream API.
19.What is the Optional class in Java 8, and why is it useful?
20.What are Default Methods in Interfaces? Why were they introduced?
21.Differentiate between map() and flatMap() in Stream API.
22.What are Method References in Java 8? Give examples of different types.
23.How do you handle immutability with Java 8 features?
24.Explain the [Link] API (New Date and Time API). What are its advantages?
Spring Boot
25.What is Spring Boot, and what are its advantages?
26.Explain the @SpringBootApplication annotation.
27.What are Spring Boot Starters? Give an example.
28.How does Spring Boot's Auto-configuration work?
29.What are Profiles in Spring Boot? How do you activate them?
30.Explain Dependency Injection (DI) and Inversion of Control (IoC) in Spring.
31.What is Spring Boot Actuator?
32.Differentiate between @Controller and @RestController in Spring Boot.
33.How do you handle externalized configuration in Spring Boot?
34.What is Spring Data JPA, and how does it simplify data access?
Microservices
35.What are Microservices, and what are their key characteristics?
36.Differentiate between Monolithic and Microservices architecture.
37.Explain Service Discovery in a Microservices architecture. Give examples of tools.
38.What is an API Gateway, and why is it important in Microservices?
39.How do Microservices communicate with each other?
40.Explain the Circuit Breaker pattern in Microservices.
41.What is eventual consistency in a Microservices environment?
42.How do you handle distributed transactions in Microservices?
43.What is Containerization (e.g., Docker) and Orchestration (e.g., Kubernetes) in the
context of Microservices?
44.What are the challenges of adopting Microservices?
Advanced & General Java
45.Explain the difference between CompletableFuture and Future in Java.
46.What is the difference between Comparable and Comparator?
47.What is the significance of Reflection API in Java?
48.Explain the concept of ThreadLocal in Java.
49.What is the purpose of volatile keyword in Java?
50.What is a "Deadlock" in multithreading, and how can it be avoided?