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
- Reverse a String without using built-in methods
- Check if a String is a palindrome
- Find the first non-repeated character in a String
- Find the most frequent character in a String
- Count occurrence of each character in a String
- Remove duplicate characters from a String
- Check if two Strings are anagrams
- Find all permutations of a String
- Find longest substring without repeating characters
- Compress a String (Example:
aaabb โ a3b2)
2. Array Problems
- Find second largest element in array
- Find missing number in array
- Move all zeros to end of array
- Rotate array by K positions
- Find duplicate numbers in array
- Merge two sorted arrays
- Find intersection of two arrays
- Find maximum subarray sum (Kadaneโs Algorithm)
- Find pair with given sum (Two Sum)
- Find top K largest elements
3. Collection Framework Coding
- Remove duplicates from a List
- Sort Map by value
- Convert List to Map using Stream API
- Find frequency of elements in List
- Implement Custom Comparator for sorting objects
Example:
Comparator<Employee> salaryComparator =
Comparator.comparing(Employee::getSalary);
4. Java 8 Stream Coding (Very Frequently Asked)
- Find max and min value in list using Streams
- Count occurrence of characters using Streams
- Convert List โ Map<String,Integer>
- Find duplicate elements using Streams
- 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
- Print odd and even numbers using two threads
- Implement Producer Consumer problem
- Create custom thread pool
- Write code that produces deadlock
- Write code to avoid deadlock
Example:
ExecutorService executor = Executors.newFixedThreadPool(5);
executor.submit(() -> {
System.out.println(Thread.currentThread().getName());
});
6. Data Structure Coding
- Reverse a Linked List
- Detect cycle in Linked List (Floyd Algorithm)
- Implement Stack using Queue
- Implement Queue using Stack
- Implement Binary Search
7. Design Pattern Coding Questions
- Implement Singleton (Thread Safe)
- Implement Factory Pattern
- Implement Builder Pattern
- 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)
- Implement LRU Cache
Concept used:
- HashMap
- Doubly Linked List
- Implement Rate Limiter
Used in:
- API Gateway
- Microservices
- Implement Retry Mechanism for API calls
Concept:
- Exponential Backoff
- Implement Cache with Expiry
Example:
- Redis style TTL cache
- Design URL Shortener (like TinyURL)
Concepts:
- Hashing
- Base62 encoding
- Database indexing
- 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);
