🔹 OOPs Concepts
1. What are the four pillars of OOP in Java?
2. What is the difference between Abstraction and Encapsulation?
3. What is inheritance in Java? Types of inheritance supported?
4. What is polymorphism? Explain method overloading and overriding.
5. Can you override a private or static method in Java?
🔹 Java Basics
6. What is the difference between JDK, JRE, and JVM?
7. How is Java platform-independent?
8. What is the main() method signature? Why is it public static void main(String[] args)?
9. What is the difference between == and .equals()?
10. What are primitive and non-primitive data types?
🔹 Classes & Objects
11. What is the difference between class and object?
12. What is a constructor? Types of constructors?
13. What is constructor overloading?
14. What is the use of the this keyword?
15. What is the use of the super keyword?
🔹 Access Modifiers
16. What are different access modifiers in Java?
17. What is the difference between default, protected, private, and public?
🔹 Inheritance & Interfaces
18. Difference between interface and abstract class?
19. Can a class implement multiple interfaces? Can it extend multiple classes?
20. What happens if a class implements two interfaces with same method signature?
🔹 Exception Handling
21. What is the difference between checked and unchecked exceptions?
22. Explain try, catch, finally, throw, and throws.
23. Can we have finally without catch?
24. What is the purpose of custom exceptions?
🔹 Collections Framework
25. Difference between ArrayList, LinkedList, Vector, and Stack?
26. What is the difference between HashMap, LinkedHashMap, and TreeMap?
27. What is the difference between Set and List?
28. What is the difference between HashSet and TreeSet?
29. What are fail-fast and fail-safe iterators?
30. When do you use HashMap vs ConcurrentHashMap?
31. Internal implementation of hashmap (1.8) and ConcurrentHashMap
32. Priority queue
33. Weekhash map
34. Concurrent modification exception
35. .equal and hashmap me contact , 2 emp object have same data then what happen
36. When hash map converted red black tree(point)
🔹 Multithreading & Concurrency
31. What is the difference between process and thread?
32. How to create a thread in Java?
33. Difference between Runnable and Thread?
34. What is the difference between synchronized method and synchronized block?
35. What is volatile keyword?
36. What is atomic integer?
37. What is a deadlock? How to prevent it?
38. What is Thread local?
39. Diff between Runnable and callable (run and call)
40. Life cycle of thread
41. Join yield
42. Consumer produce and even odd program. WAP using 3 thread print number sequences
43. Executor framework and way to create thread
44. Lock
45.
🔹 Memory Management
37. What is the garbage collector in Java?
38. What are heap and stack memory , method area , ?
39. Memory leak
40. What is the difference between final, finally, and finalize()?
41. What are strong, weak, soft, and phantom references?
42. Memory architecture (VVI)
🔹 Java Keywords & Concepts
41. Difference between == and equals()?
42. What is the use of static keyword?
43. What is the difference between final, static, and abstract?
44. What is a wrapper class in Java?
45. Explain auto-boxing and unboxing.
🔹 Java 8 Features (Frequently Asked Now)
46. What is a lambda expression?
47. What are functional interfaces?
48. What is Stream API? Use cases?
49. What are default and static methods in interfaces?
50. What is Optional in Java?
51. Different between map and flatmap
52. Parraller stream how to customized paraller stream
53. Termination and intermediate method
54. Function Consumer predicate Supplier BiConsumer and Bifunction
🔹 Spring Core
1. What is the Spring Framework? Why is it used?
2. What are the main features of Spring Framework?
3. What is Inversion of Control (IoC)?
4. What is Dependency Injection (DI)? How is it implemented in Spring?
5. What is the difference between @Component, @Service, @Repository, and @Controller?
6. What is the difference between BeanFactory and ApplicationContext?
7. How does Spring manage bean scopes (singleton, prototype, etc.)?
8. What are different types of DI – constructor vs setter injection?
9. How do you define a bean in Spring?
10. What is the Spring bean lifecycle?
11. Most preferable DI
🔹 Spring Boot
11. What is Spring Boot? How is it different from Spring?
12. What are the main features of Spring Boot?
13. What is @SpringBootApplication annotation?
14. How does Spring Boot autoconfiguration work?
15. What is application.properties / application.yml used for?
16. How do you create a REST API in Spring Boot?
17. What is the use of @RestController vs @Controller?
18. How does Spring Boot handle embedded servers like Tomcat or Jetty?
19. What is Actuator in Spring Boot?
20. How do you customize error handling in Spring Boot?
🔹 Spring MVC
21. What is Spring MVC architecture?
22. How does request mapping work in Spring MVC (@RequestMapping, @GetMapping, etc.)?
23. How does Spring MVC handle form data and file uploads?
24. What is ModelAndView?
25. How do you handle exceptions in Spring MVC?
🔹 Spring Data JPA / Hibernate
26. What is Spring Data JPA?
27. What is the difference between JpaRepository, CrudRepository, and
PagingAndSortingRepository?
28. How does Spring Boot auto-configure DataSource and JPA?
29. What is the difference between @OneToOne, @OneToMany, @ManyToOne, and
@ManyToMany?
30. What is the N+1 problem in JPA?
31. How do you implement pagination and sorting with Spring Data JPA?
🔹 Spring Security
32. What is Spring Security?
33. How does Spring Security authenticate and authorize requests?
34. What is the use of UserDetailsService?
35. How do you implement JWT with Spring Security?
36. How do you secure REST APIs with Spring Security?
🔹 Spring Boot Microservices
37. What is the difference between monolithic and microservices architecture?
38. How do you implement inter-service communication (RestTemplate, WebClient, Feign)?
39. What is Spring Cloud?
40. What is service discovery (Eureka)?
41. How do you use Spring Cloud Config Server?
42. What is Circuit Breaker (Resilience4j or Hystrix)?
43. How do you secure microservices (OAuth2, JWT)?
44. How do you handle centralized logging in microservices (e.g., ELK stack)?
🔹 General and Advanced
45. How do you handle transactions in Spring? (@Transactional)
46. What is AOP (Aspect-Oriented Programming)?
47. How does @Async work in Spring?
48. How do you schedule tasks in Spring (@Scheduled)?
49. What is the difference between synchronous and asynchronous communication in
microservices?
50. How do you write unit tests and integration tests in Spring Boot (MockMvc, WebTestClient,
@SpringBootTest)?
/////////////////////////////////////////////////////////////////////////////////////////////////
🔹 Spring Boot – Extended Questions
✅ Configuration & Properties
1. What is the difference between @Value and @ConfigurationProperties?
2. How do you externalize configuration in Spring Boot?
3. How can you use different profiles in Spring Boot (@Profile)?
4. How do you inject values from application.yml into a bean?
✅ Starter Dependencies & Auto-Configuration
5. What are Spring Boot starters? Name some commonly used ones.
6. How does auto-configuration work under the hood?
7. How do you disable auto-configuration for a specific class or component?
8. What is the purpose of spring.factories?
✅ RESTful API Design
9. How do you version REST APIs in Spring Boot (URI vs Header-based)?
10. How do you validate request bodies in Spring Boot (@Valid, @Validated)?
11. What is the difference between @RequestParam, @PathVariable, and @RequestBody?
12. How do you handle custom exceptions with @ControllerAdvice and @ExceptionHandler?
✅ Database and JPA Enhancements
13. How do you configure multiple data sources in Spring Boot?
14. What is Lazy vs Eager loading in JPA?
15. How do you write dynamic queries using @Query and QueryDSL or Specifications?
16. How do you use Liquibase or Flyway with Spring Boot?
✅ Spring Boot Testing
17. What is the difference between @WebMvcTest, @DataJpaTest, and @SpringBootTest?
18. How do you mock dependencies using Mockito in Spring Boot tests?
19. What is TestRestTemplate? How is it used in integration testing?
20. How do you write unit tests for controllers or services?
✅ Security (Expanded)
21. How does Spring Security work with custom authentication providers?
22. What is CSRF protection? How do you disable it for APIs?
23. How do you secure endpoints using method-level security (@PreAuthorize, @Secured)?
24. How do you implement role-based authorization?
✅ Spring Boot with Kafka, RabbitMQ, etc.
25. How do you integrate Kafka in a Spring Boot application?
26. What is the difference between Kafka consumer groups and partitions?
27. How do you implement retry logic and dead letter queues in Kafka or RabbitMQ?
✅ Spring Boot with Swagger/OpenAPI
28. How do you document APIs using Swagger (springdoc-openapi or springfox)?
29. How can you customize API documentation (title, description, version)?
30. How do you hide certain endpoints from Swagger documentation?
✅ Monitoring & DevOps
31. How do you monitor Spring Boot applications using Actuator?
32. How do you expose custom metrics using Micrometer?
33. How can you deploy Spring Boot applications as Docker containers?
34. How do you manage Spring Boot deployments in Kubernetes?
✅ Performance and Best Practices
35. How do you optimize memory and startup time of Spring Boot apps?
36. What are best practices for REST API error handling in Spring Boot?
37. How do you prevent N+1 query problems in Spring Boot + JPA?
38. How do you handle long-running tasks or background jobs?
Microservice :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Microservices – Most Asked Interview Questions
🔹 Basic Microservices Concepts
1. What are microservices? How are they different from monolithic architecture?
2. What are the advantages and disadvantages of microservices?
3. What are the key characteristics of microservices architecture?
4. How do microservices communicate with each other?
o Synchronous (REST, gRPC)
o Asynchronous (Kafka, RabbitMQ)
5. What challenges do you face when developing microservices?
🔹 Spring Boot & Microservices
6. How do you create a microservice using Spring Boot?
7. How do you expose and consume REST APIs between microservices?
8. What is the role of RestTemplate and WebClient in inter-service communication?
9. How do you implement service versioning in microservices?
10. How do you handle exceptions and validation in REST APIs?
🔹 Service Discovery & Load Balancing
11. What is Eureka Server? How does it work in Spring Cloud?
12. What is the role of Eureka Client?
13. How does Ribbon work as a client-side load balancer?
14. What is Spring Cloud LoadBalancer?
15. How do you handle dynamic scaling of microservices?
🔹 API Gateway
16. What is an API Gateway and why is it used in microservices architecture?
17. How do you implement API Gateway using Spring Cloud Gateway?
18. What is the difference between Zuul and Spring Cloud Gateway?
19. How do you handle routing, filtering, and security in an API Gateway?
20. How do you implement rate limiting or throttling in API Gateway?
🔹 Configuration Management
21. What is Spring Cloud Config Server?
22. How do you store and manage configuration for multiple microservices?
23. How do you update configuration in running services (without redeployment)?
24. What is the use of Git in Spring Cloud Config?
🔹 Security in Microservices
25. How do you secure microservices APIs?
26. What is OAuth2 and how do you use it in microservices?
27. What is JWT (JSON Web Token)?
28. How do you implement token-based authentication in Spring Security?
29. How does API Gateway handle authentication and authorization?
🔹 Distributed Transactions
30. How do you handle transactions across multiple microservices?
31. What is the Saga Pattern?
32. What is 2PC (Two-Phase Commit), and why is it not recommended in microservices?
33. How do you implement Saga using Kafka or orchestration/choreography?
🔹 Communication and Messaging
34. What are the differences between synchronous and asynchronous communication?
35. When do you use Kafka or RabbitMQ in microservices?
36. How do you achieve eventual consistency with messaging queues?
37. How do you handle message retries and dead-letter queues?
🔹 Monitoring & Resilience
38. What is Circuit Breaker pattern?
39. What is Resilience4j or Hystrix?
40. What is fallback method in circuit breakers?
41. How do you monitor microservices (Actuator, Prometheus, Grafana)?
42. What is distributed tracing (Zipkin, Sleuth)?
🔹 Deployment, Scaling & DevOps
43. How do you deploy microservices using Docker?
44. What is the role of Kubernetes in microservices deployment?
45. How do you scale microservices independently?
46. What are the best practices for CI/CD in microservices?
🔹 Data Management
47. Should microservices share a database? Why or why not?
48. How do you manage schema changes in microservices?
49. What is the Database per Service pattern?
50. How do you handle reporting across microservices with separate databases?
//////////////////////////////////////////////////////////////////////////////////////////////////
✅ Most Asked REST API Interview Questions
🔹 REST Basics
1. What is a REST API?
2. What are the key principles of REST architecture?
o Statelessness
o Uniform interface
o Client-server
o Cacheable
o Layered system
3. What is the difference between REST and SOAP?
4. What are HTTP methods used in REST APIs?
o GET, POST, PUT, PATCH, DELETE
5. What is the difference between PUT and PATCH?
🔹 API Design
6. What is a resource in REST?
7. How should you design URLs in RESTful services?
o /users/123 ✅
o Avoid verbs in URL like /getUsers ❌
8. How do you implement versioning in REST APIs?
o URI versioning: /api/v1/users
o Header versioning
9. What is idempotency and which HTTP methods are idempotent?
10. What is a status code? List some common HTTP status codes:
o 200 OK
o 201 Created
o 204 No Content
o 400 Bad Request
o 401 Unauthorized
o 403 Forbidden
o 404 Not Found
o 500 Internal Server Error
🔹 Request/Response Handling
11. What is the difference between @RequestParam, @PathVariable, and @RequestBody in
Spring Boot?
12. How do you send a file or image in a REST API?
13. What is content negotiation?
14. What are the common MIME types used?
o application/json
o application/xml
15. How do you handle large payloads and pagination in REST APIs?
🔹 Validation & Exception Handling
16. How do you validate incoming requests in Spring Boot?
o @Valid, @Validated, @NotNull, etc.
17. How do you handle custom exceptions globally?
o Using @ControllerAdvice and @ExceptionHandler
18. How do you return a custom error response from a REST API?
19. What is a 422 Unprocessable Entity response and when should it be used?
20. How do you handle invalid JSON input?
🔹 Security
21. How do you secure REST APIs?
22. What is the difference between basic auth, token auth, and OAuth2?
23. How does JWT (JSON Web Token) work?
24. How do you implement role-based access control (RBAC)?
25. How can API Gateway help in securing REST APIs?
🔹 Testing & Tools
26. What tools do you use to test REST APIs?
o Postman, Swagger, curl
27. What is Swagger/OpenAPI? How do you integrate it in Spring Boot?
28. How do you test REST APIs in Spring Boot?
o MockMvc, TestRestTemplate
🔹 Advanced & Best Practices
29. What are RESTful best practices?
o Use nouns for URIs, proper HTTP status codes, versioning, HATEOAS, etc.
30. What is HATEOAS?
31. Should a REST API return only data or also include metadata/links?
32. How do you handle API rate limiting?
33. What is throttling and how can you prevent abuse of your APIs?
34. How do you handle backward compatibility in APIs?
35. What is the difference between synchronous and asynchronous APIs?