Top 50 Java coding questions for 10+ years experience

For 10+ years Java developers, interviewers focus on advanced coding, concurrency, collections, Java 8+, performance optimization, and system-level problem solving.

Below is a carefully curated list of Top 50 Java Coding Interview Questions commonly asked for Senior / Lead / Architect level roles.


Top 50 Java Coding Interview Questions (10+ Years Experience)

1. String Problems

  1. Reverse a String without using built-in methods
  2. Check if a String is a palindrome
  3. Find the first non-repeated character in a String
  4. Find the most frequent character in a String
  5. Count occurrence of each character in a String
  6. Remove duplicate characters from a String
  7. Check if two Strings are anagrams
  8. Find all permutations of a String
  9. Find longest substring without repeating characters
  10. Compress a String (Example: aaabb โ†’ a3b2)

2. Array Problems

  1. Find second largest element in array
  2. Find missing number in array
  3. Move all zeros to end of array
  4. Rotate array by K positions
  5. Find duplicate numbers in array
  6. Merge two sorted arrays
  7. Find intersection of two arrays
  8. Find maximum subarray sum (Kadaneโ€™s Algorithm)
  9. Find pair with given sum (Two Sum)
  10. Find top K largest elements

3. Collection Framework Coding

  1. Remove duplicates from a List
  2. Sort Map by value
  3. Convert List to Map using Stream API
  4. Find frequency of elements in List
  5. Implement Custom Comparator for sorting objects

Example:

Comparator<Employee> salaryComparator =
Comparator.comparing(Employee::getSalary);

4. Java 8 Stream Coding (Very Frequently Asked)

  1. Find max and min value in list using Streams
  2. Count occurrence of characters using Streams
  3. Convert List โ†’ Map<String,Integer>
  4. Find duplicate elements using Streams
  5. Sort objects using Streams

Example:

List<Integer> list = Arrays.asList(10,20,5,30);

int max = list.stream()
              .max(Integer::compare)
              .get();

5. Multithreading Coding Problems

  1. Print odd and even numbers using two threads
  2. Implement Producer Consumer problem
  3. Create custom thread pool
  4. Write code that produces deadlock
  5. Write code to avoid deadlock

Example:

ExecutorService executor = Executors.newFixedThreadPool(5);

executor.submit(() -> {
    System.out.println(Thread.currentThread().getName());
});

6. Data Structure Coding

  1. Reverse a Linked List
  2. Detect cycle in Linked List (Floyd Algorithm)
  3. Implement Stack using Queue
  4. Implement Queue using Stack
  5. Implement Binary Search

7. Design Pattern Coding Questions

  1. Implement Singleton (Thread Safe)
  2. Implement Factory Pattern
  3. Implement Builder Pattern
  4. Implement Observer Pattern

Example Singleton:

public class Singleton {

    private static volatile Singleton instance;

    private Singleton(){}

    public static Singleton getInstance(){
        if(instance == null){
            synchronized (Singleton.class){
                if(instance == null){
                    instance = new Singleton();
                }
            }
        }
        return instance;
    }
}

8. Real-World System Coding Problems (Senior Level)

  1. Implement LRU Cache

Concept used:

  • HashMap
  • Doubly Linked List

  1. Implement Rate Limiter

Used in:

  • API Gateway
  • Microservices

  1. Implement Retry Mechanism for API calls

Concept:

  • Exponential Backoff

  1. Implement Cache with Expiry

Example:

  • Redis style TTL cache

  1. Design URL Shortener (like TinyURL)

Concepts:

  • Hashing
  • Base62 encoding
  • Database indexing

  1. Implement Circuit Breaker Pattern

Used in Microservices resilience


Most Important Topics for 10+ Years Java Developers

Interviewers usually test:

โœ” Java 8 Streams
โœ” Concurrency (Thread, Executor, CompletableFuture)
โœ” Collections internal working
โœ” Memory management (Heap, Stack, GC)
โœ” Design patterns
โœ” Microservices coding problems
โœ” Performance optimization


Real Interview Example (Very Common)

Example question:

Find duplicate elements using Stream

List<Integer> list = Arrays.asList(1,2,3,2,4,5,3);

Set<Integer> duplicates =
list.stream()
    .filter(i -> Collections.frequency(list,i) > 1)
    .collect(Collectors.toSet());

System.out.println(duplicates);
Share with