DEV Community

Vivek Nishant
Vivek Nishant

Posted on AI-assisted

2026 - Backend Interview Questions

1. Core Java & OOP

  1. Write an immutable class in Java
  2. Comparable vs Comparator with examples
  3. What is a Functional Interface? Can it have default and static methods?
  4. Explain try-with-resources. What happens if both try and close() throw exceptions?

2. JVM, Memory & Performance

  1. JVM memory management
  2. Your Java application has high GC pauses in production — what would you investigate?
  3. How would you identify a memory leak in a Java application?

3. Concurrency & Multithreading

  1. Multithreading
  2. Producer–Consumer problem
  3. Deadlock example in Java
  4. Implement a thread-safe Singleton using double-checked locking

4. Collections & Internals

  1. Collections internal working
  2. HashMap internal working
  3. How does HashMap handle collisions internally?
  4. ConcurrentHashMap vs HashMap — scenario-based
  5. Explain the internal working of ConcurrentHashMap
  6. Process a large ConcurrentHashMap using multiple threads safely

5. Java 8 & Streams

  1. How does Java 8 Stream API work internally?
  2. Difference between map() vs flatMap() with a real-world example
  3. Write a Java 8 program using flatMap() to flatten a nested list
  4. Sort Employee list using Comparator & Streams
  5. Sort employees by salary
  6. Find Top N highest salaries using Streams
  7. Find employee with highest salary
  8. Find employee with second highest salary
  9. Find the highest-paid employee from each department using Streams
  10. Group employees by department
  11. Count employees by department
  12. Convert List to Map using Streams
  13. Remove duplicates using Streams
  14. Find duplicate elements using Streams
  15. Find highest number in a list using Streams
  16. Find second highest number in a list using Streams
  17. Find first non-repeating character using Streams
  18. Find second non-repeating character using Streams
  19. Count character frequency using Streams
  20. Find employees joining after a given year

6. Data Structures — Arrays & Lists

  1. Find duplicate elements in an array
  2. Merge two sorted arrays
  3. Find all unique triplets whose sum equals a given target
  4. Find duplicate elements in a list
  5. Remove duplicates from a list
  6. Find the highest number in a list
  7. Find the second highest number in a list

7. Data Structures — Strings

  1. Find first non-repeating character in a string
  2. Find second non-repeating character in a string
  3. Find first repeating character in a string
  4. Reverse a string without using inbuilt methods
  5. Reverse words in a sentence
  6. Find longest substring without repeating characters
  7. Find the length of the longest substring containing at most K distinct characters
  8. How would you optimize the K-distinct substring problem to O(n)?
  9. What changes if K = 2?
  10. How would you manage character frequencies efficiently?
  11. Count frequency of characters using HashMap
  12. Remove duplicate characters from a string
  13. String rotation (ajith → thaji)

8. Data Structures — Stacks, Caching & Classic Problems

  1. Balanced parentheses problem using Stack
  2. Implement LRU Cache

9. Algorithms & Sorting

  1. Implement Merge Sort and explain its time and space complexity

10. Spring Boot & REST APIs

  1. CompletableFuture real-time scenario
  2. Retry failed REST API calls
  3. Pagination implementation in Spring Boot
  4. Rate Limiter implementation
  5. Spring Boot exception handling
  6. REST API best practices
  7. How would you design an API that can handle 10K+ requests per second?
  8. How would you prevent duplicate orders if the same request is received twice?
  9. How would you design an API so that it remains backward compatible when the response structure changes?
  10. How does @Transactional work internally in Spring Boot?
  11. How does Dependency Injection work internally in Spring?

11. SQL & Databases

  1. Find the second-highest salary from an Employee table
  2. Find nth highest salary
  3. Find employees having the same salary
  4. Department-wise maximum salary query
  5. Count employees department-wise
  6. Remove duplicate records from a table
  7. Find duplicate rows in a table
  8. Difference between WHERE and HAVING
  9. INNER JOIN vs LEFT JOIN
  10. Pagination using LIMIT & OFFSET
  11. How would you design pagination for millions of records?
  12. SQL optimization
  13. Indexing, composite indexes, and query execution plans
  14. How would you optimize a slow query running on millions of records?
  15. Your database has 100 million records and a query suddenly becomes slow — how would you investigate?
  16. What happens when your database becomes unavailable for 30 seconds?
  17. Two requests update the same DB record simultaneously — how would you handle the race condition?

12. Kafka & Asynchronous Messaging

  1. How would you prevent duplicate processing of Kafka messages?
  2. Kafka is receiving messages faster than consumers can process them — how would you solve it?
  3. How would you handle a Kafka message that repeatedly fails?

13. Microservices & System Design

  1. Microservices communication
  2. How would you design microservices for high availability?
  3. API Gateway vs Load Balancer — what is the difference?
  4. How would you handle failures between two microservices?
  5. One microservice is down — how should dependent services behave?
  6. Explain Circuit Breaker, Retry and Timeout patterns
  7. Retry vs Timeout vs Circuit Breaker — when would you use each?
  8. How would you design a retry mechanism without creating a retry storm?
  9. How would you prevent one slow downstream service from exhausting your application's threads?
  10. How would you maintain consistency when a business operation spans multiple microservices?
  11. How would you handle distributed transactions?
  12. How would you handle duplicate requests?
  13. Designing a scalable payment/transaction backend
  14. What happens if the payment succeeds, but your service crashes before sending the response?
  15. Duplicate payments, idempotency, consistency, retries, and event-driven processing
  16. How would you migrate a Java application from on-premise to Cloud?

14. Debugging, Observability & Performance Tuning

  1. Your API is slow, but CPU and memory are normal — how would you find the bottleneck?
  2. An API's latency suddenly increases from 200ms to 5 seconds — how would you debug it?
  3. Your system works perfectly at normal traffic but fails during a sudden traffic spike — walk me through your debugging approach.
  4. How would you monitor and troubleshoot a production microservices application?

Top comments (0)