Learning roadmap
A guided path from fundamentals to advanced — work through each stage in order.
1
Search in rotated sorted array / linked list edge casesWhat are the different types of inner classes in Java — member, static nested, local, and anonymous?What is the difference between Minor GC, Major GC, and Full GC?What is the difference between JDK, JRE, and JVM?Why is Java not considered a purely Object-Oriented language?Explain the different types of polymorphism, especially runtime polymorphism, with an example.What is the difference between ArrayList and LinkedList — when to use which?Explain the 4 pillars of OOP with real-world examples.How does a Java program actually run, from source file to execution?What is the difference between Comparable and Comparator?Can we overload a method by changing only its return type?Binary Tree: Preorder Traversal + Maximum Path SumWhat is the difference between a static nested class and a (non-static) inner class in Java?What is an OutOfMemoryError vs StackOverflowError?Synchronization vs Concurrent Collections — when & why?What is a local inner class in Java? What are the rules around accessing variables from its enclosing method?What is the difference between == and .equals() in Java?Why is Java called a platform-independent language?Binary Search: Koko Eating Bananas / minimum eating speedG1 GC vs ZGC vs Shenandoah — when would you choose each?Can we overload the main() method? Which one does the JVM execute?What is method overloading vs method overriding?Quick SortWhy doesn't Java use pointers the way C/C++ does?Heap keeps growing even after a Full GC runs. How do you debug it?What are anonymous inner classes in Java, and what are their restrictions compared to named classes?Predicate, Function, Consumer, Supplier — explain and differentiateDifference between this and super keywords.What is the difference between abstract class and interface?What is the difference between byte streams and character streams in Java I/O — when do you use InputStream/OutputStream vs Reader/Writer?What is the difference between List and Set in Java?Why use HashMap instead of nested loops?Production throws OutOfMemoryError: Metaspace. What could cause it?How do you create and handle custom exceptions?Anagram and its variations (DSA)Difference between BufferedInputStream and BufferedOutputStreamDifference between == and .equals()?Spiral printing of a matrix (DSA)Explain the 'static' keyword — static variable, method, block, class.Java heap is stable, but overall process memory keeps growing. Why?What is the difference between HashSet, LinkedHashSet, and TreeSet?What is the difference between FileReader and BufferedReader, and why does wrapping one in the other improve performance?What is the difference between CopyOnWriteArraySet and a regular HashSet?What is the difference between java.io and java.nio? What does NIO's non-blocking, buffer-based model actually change?Your application pauses frequently, but GC logs look completely normal. What's going on?What is the difference between pass-by-value and pass-by-reference in Java?Find the highest number in a random matrix using threadsDifference between JVM, JRE and JDK?What are Filter Streams?Modify the solution to find all non-repeating elements while maintaining their orderExplain the String Pool.What is the difference between Comparable and Comparator in Java?Why should file handling code always use try-with-resources instead of manually closing streams in a finally block?What is Serialization, and where have you used it?What is Escape Analysis? Why is it useful?What is autoboxing and unboxing?What is the difference between Project Loom and traditional threads?Which encryption/hashing mechanism do you use for storing passwords?What is the difference between Collection and Collections in Java?What is the Parent Delegation Model in class loading, and why is it important?What is the diamond problem and how does Java 8 solve it with default methods?Why is String immutable in Java?How do Java enums work internally? What do values(), ordinal(), and valueOf() actually do?Explain how 'instanceof' works and what pattern matching for instanceof (Java 16) does.Merge two sorted arrays (nums1, nums2) in-place into nums1 without returning a new array (LeetCode 88 style)Find the number of trailing zeroes in the factorial of a given number (coding)Why must equals() and hashCode() be consistent? What happens if they are implemented incorrectly?What is the difference between the Collections Framework and the Streams API?Can a Java enum have constructors, fields, and methods? Can each enum constant override a method differently?How do you capture and analyze a heap dump using Eclipse MAT — what do you actually look for?What is String immutability? Why is String immutable in Java?Why are enums a good fit for switch statements and as HashMap/EnumMap keys?Write a Java program to find words that can be typed using letters from only one row of a QWERTY keyboardWhat are the key features introduced in Java 8?Check whether two strings are anagramsWhat is TLAB (Thread Local Allocation Buffer) and how does it improve allocation performance?What are the access modifiers in Java, and what does each one control?What is the difference between this and super keywords in Java?What is GC ergonomics and how does the JVM auto-tune GC settings?Given an Employee list, group employees by department and find the employee with the highest salary in each departmentWhy do we need async and await? What happens when you call an asynchronous API? Difference between async programming and multithreading?Difference between map() and flatMap().What is the String constant pool?Given an integer array, find all the prime numbers present in the arrayCan a constructor be declared final or static in Java?What are intermediate and terminal operations in the Stream API?What is the difference between String, StringBuilder, and StringBuffer?Find the second-highest salary in each department using Java StreamsWhy do Virtual Threads become pinned and lose scalability?Complementary string pairs — count pairs where some permutation of their concatenation is a palindromeFunctional interface vs marker interface.Can you override a private or static method in Java?What is structured concurrency in Java 21+ and why is it better than raw CompletableFuture chains?Find the longest palindromic substring.What is an enum type? How do you compare two enum values?Cheapest flights within K stops (graph + BFS)What happens when we try to reuse a stream?What is a marker interface in Java? Give an example.Explain Lombok and its advantagesMinimum window substring — find the smallest window in S containing all characters of T.Why are exceptions inside CompletableFuture chains often missed silently?ConcurrentHashMap is thread-safe, yet race conditions can still exist in code that uses it. Why?Can you catch multiple exception types in a single catch block?What is the difference between Array and ArrayList?What are some benefits of using Streams?Difference between abstraction and interfaceImplement a Sudoku solver — full running code, test cases checkedWhat are Records in Java? Do Records have equals() and hashCode()?Can you throw a checked exception inside a lambda expression's body?Why can increasing the thread pool size actually reduce application performance?Find the maximum subarray sum (Kadane's algorithm).Explain Java 8 Streams and Lambda expressions.Implement a thread-safe task schedulerSort an array of 0s, 1s, and 2s in a single pass (Dutch National Flag).Design a distributed rate limiter — first defend which algorithm, then design itWhat is a Stream, and how is it different from a Collection?What are the different ways to create a thread in Java?What is Method Hiding in Java? How would you implement it?What is the difference between synchronized, ReentrantLock, and StampedLock?What is lazy evaluation in Java Streams?What changed in HashMap in Java 8 compared with previous versions?What is the difference between CountDownLatch, CyclicBarrier, and Semaphore?Can you start the same Thread object twice in Java?Implement a bounded queue. Then build a thread pool on top of it — no ExecutorService allowedTrapping rainwater problem — compute how much water can be trapped.What are the different states in a Java thread's lifecycle?Difference between filter(), map() and reduce().A playground supports one team at a time, with ten players maximum — assign players without starvationIf two threads access and modify the same HashMap concurrently, what can go wrong?Find the longest increasing subsequence (LIS).How does ForkJoinPool differ from a regular ThreadPoolExecutor?What happens when you submit too many tasks to a ThreadPoolExecutor — what are the rejection policies?Given a list of Strings, how would you filter strings with length greater than 3, sort them based on length, and return the top 3 strings?What is the difference between Runnable and Callable interfaces in Java?Explain the Collections hierarchy — List, Set, Map, Queue.Concurrent searchers, inserters and deleters on a linked list — searches concurrent, one insert at a time, deletion blocks allDifference between findFirst() and findAny().What is a race condition and how is it different from a data race?What are Method References in Java, and what are the 4 types?How does distinct() work in a Stream?How does HashMap work internally? (hashing, buckets, collision)How do you make a LinkedList synchronized?Implement file read/write using offsets, then make it multithreadedWhat is abstraction? Explain with a real-world/project example. When would you use an abstract class instead of a normal class?Alien Dictionary — topological sort, with executable codeHow does Collectors.groupingBy() work in the Stream API? Give an example.How do you sort objects using Java Streams?What is the difference between HashMap and Hashtable?A ThreadLocal variable in your app is causing a memory leak. How does that happen, and how do you fix it?How do you group and partition data using Collectors.groupingBy() and partitioningBy()?A HashMap has millions of entries and suddenly becomes slow. How would you investigate?What is a static class? Why do we need it? Where have you used it (Helper/Utility example)?What is the Function functional interface in Java, and when do you use it?Find the median from a data stream, then optimize for approximate median in constant time and spaceHow does ConcurrentHashMap differ from HashMap?Stream.toList() vs Collectors.toList().Longest subarray where max minus min stays within a limitYou insert a mutable object as a HashMap key and later modify it. What can go wrong?What is fail-fast vs fail-safe iterator?What is the Predicate functional interface in Java, and when do you use it?What is multithreading? When would you use multiple threads in a real application? How is it different from asynchronous programming?Sequential stream vs parallel stream: how do they differ?How would you find duplicate records in a table without using GROUP BY?Implement an LRU cache using LinkedHashMap.Your CopyOnWriteArrayList is creating high memory usage and GC pressure. Why?Machine coding: in-memory Twitter — createUser, postTweet, getNewsFeed, follow, unfollowWhat is the Supplier functional interface in Java, and when do you use it?What is the Consumer functional interface in Java, and when do you use it?How many types of Garbage Collectors are there in Java?When should you avoid using parallelStream()?What happens when HashMap capacity exceeds load factor? Explain rehashing.A ConcurrentModificationException occurs in a single-threaded application. How is that possible?Machine coding: train and platform scheduler — working implementation in 60-75 minutesWhen does a HashMap bucket become a Red-Black Tree?Machine coding: in-memory pull-based queue with multiple publishers and consumersYou're reviewing production code using Collections.synchronizedMap(). Would you keep it or replace it? What factors decide?Using Streams, find duplicate elements, the frequency of each element, and the second-highest value (for example, second-highest salary).What are the key features introduced in Java 8?What are the BiFunction, BiPredicate, and BiConsumer functional interfaces?A Stream-based operation is slow in production. How would you identify and optimize the bottleneck?What are UnaryOperator and BinaryOperator, and how do they differ from Function and BiFunction?What is a functional interface? Can you write a custom one?Sort a map by valueMachine coding: implement mkdir, pwd and cd (cd supports wildcards)Why can a poor hashCode() implementation destroy HashMap performance?What is the difference between map() and flatMap() in Streams?Two threads call computeIfAbsent() for the same key on a ConcurrentHashMap at the same time. What behavior do you expect?A HashMap key's hashCode changes after insertion. What does get() return for that key?What is the difference between final, finally, and finalize()?Number of Islands — then implement it in Java, without prior noticeWhat are primitive functional interfaces in Java, and why do they exist?What is EnumMap and why is it more performant than HashMap for enum keys?What is the Optional class? How does it prevent NullPointerException?How does IdentityHashMap differ from a normal HashMap?Find the middle node of a linked list in one passWhat is the difference between composition and inheritance? When would you prefer one over the other?What does the Stream filter() method do, and how is it different from map()?What is the difference between lazy and eager evaluation in Streams? Explain with an example.You need the top 10 most frequent items out of millions of events. Which collections would you combine to solve this efficiently?What does the Stream collect() method do, and what's the difference between collect() and forEach()?How can null be handled in a TreeSet?What is the difference between synchronized method and synchronized block?Print the left view of a binary treeWhat is a cache map in Java collections?What does the Stream distinct() method do, and how does it determine uniqueness?Given a graph with V vertices and E edges, detect if it contains a cycleA cache should automatically release entries when their keys are no longer strongly referenced elsewhere. What would you use?What is the difference between checked and unchecked exceptions?How would you identify legacy classes suitable for conversion to Java 17 records?What is try-with-resources? How does it differ from traditional try-catch-finally?Difference between List, Set and Map.Benefits and challenges of records in business models?Find the nth Fibonacci number for n <= 30Are Java Records truly immutable? What are their limitations?What do the Stream limit() and skip() methods do?What are Sealed Classes in Java 17 — how do they enforce domain modeling?How do you create a custom exception? Give checked and unchecked examples.Merge overlapping intervals given N intervalsHashMap has 1 million entries. Performance is degrading. Why, and how would you resolve it?What does the Stream count() method do, and how does it interact with filter()?Difference between Collection and Collections.What is exception chaining?What is the difference between anyMatch(), allMatch(), and noneMatch() in the Stream API?What is Pattern Matching for switch (Java 21) and how does it improve type-safe branching?Reverse a linked list in groups of kHow does HashSet work internally? What happens when you add an object to a HashSet?wait vs sleep. How can incorrect usage lead to deadlocks?What are Sequenced Collections in Java 21?Aggregation vs composition?Difference between HashMap, LinkedHashMap and TreeMap.Find the longest common subsequence between two stringsWhat is the difference between ClassNotFoundException and NoClassDefFoundError?Why does HashMap allow one null key?Difference between HashSet, LinkedHashSet and TreeSet.Check if a binary tree is height-balancedWhat is the difference between a Thread and a Process?How does Java 21's virtual thread implementation handle blocking I/O internally — what is carrier thread pinning?Find the kth largest element in an unsorted arrayWhat is the difference between wait(), notify(), and notifyAll()?Why doesn't ConcurrentHashMap allow null keys/values?What is the difference between var (Java 10) and explicitly typed declarations — when does var hurt readability?Why can an ArrayList become a performance problem with a very large dataset?Future vs CompletableFuture. Give a real-life example of where it is used.What is a deadlock? How can you detect and prevent it?Java 7 vs Java 8+ ConcurrentHashMap?Write a program where thread 1 computes (a+b), thread 2 computes (c+d), and the main thread multiplies the two resultsJava 25 Compact Object Headers (JEP 519) — what does it mean for production workloads?Why can CompletableFuture still block your application?ArrayList vs Vector?What is the Sliding Window pattern in DSA, and what class of problems does it solve efficiently?Difference between ExecutorService, ForkJoinPool, and a plain ThreadWhat is the volatile keyword in Java?What is ExecutorService? How is it better than creating raw threads?How do you make a HashMap thread-safe without using ConcurrentHashMap?Difference between Runnable and Callable.Why should an immutable class generally be final?What is the two-pointer pattern? Give an example problem where it turns an O(n²) solution into O(n).What is the fast & slow pointers pattern? How does it detect a cycle in a linked list?What is a thread-safe Singleton? Implement double-checked locking.What is a defensive copy and why is it needed?Difference between start() and run().Difference between @Async and a manually managed thread pool in SpringDifference between wait(), sleep() and join().What happens internally when 100 tasks are submitted to a ThreadPoolExecutor with only 8 worker threads?What is the transient keyword?What is the Java Memory Model (JMM)? Explain happens-before.What is the merge intervals pattern? Walk through merging a list of overlapping intervals.What is CompletableFuture? How does it differ from Future?volatile vs AtomicIntegerWhat is synchronization in Java?Instruction Reordering & Memory BarriersWhat is the Top K Elements pattern using a heap, and why is it more efficient than sorting the entire dataset?Reverse a Singly Linked ListMove all zeroes to the endDifference between a process and a thread.Atomicity & Race Conditions — check-then-act, read-modify-write, and why count++ isn't safeWhat is the 0/1 Knapsack dynamic programming pattern, and what other problems share its structure?What is the topological sort graph pattern? How does it apply to a course-scheduling / build-order problem?Detect a loop in a Linked Listvolatile vs synchronized: when would you use volatile?synchronized & Monitors — intrinsic locks, owner/entry set/wait set, reentrant semanticsLongest common prefixMissing number in a consecutive arrayLRU Cache implementationWhat is the latest LTS Java version? Key features and differences between Java 17 and Java 21 (Virtual Threads, Sequenced Collections, Pattern Matching)Difference between synchronized, Lock and Atomic classes.Find the Kth largest element in a stream of numbers, where new numbers keep arriving.Binary Tree TraversalsHow does Stream API work internally?Why are immutable objects useful in multithreaded applications?What is a deadlock? How do you identify and prevent it in production?Implement an LFU (Least Frequently Used) Cache with O(1) get and put.What is ExecutorService?Find the median from a data stream — numbers keep arriving one at a time, and you must return the median at any point.Implement a custom Iterator and a custom ExceptionValidate a Binary Search Tree (BST)When would you choose AtomicInteger over synchronized?Solve the Word Ladder problem — find the shortest transformation sequence from one word to another, changing one letter at a time.Dijkstra's Shortest Path AlgorithmUsing Java Streams, process transaction data and find the Top 3 clients by transaction amountWhat is a race condition?Find the digital root of an integerTopological SortDifference between Thread class and Runnable interfaceWhat happens if an exception occurs inside an ExecutorService task?Analyze a multithreading scenario involving synchronized instance vs static methodsWhat are the different memory areas in JVM?An @Async method throws an exception. Nobody catches it. What happens?Is a given interface with equals(), toString(), and a default method still a valid @FunctionalInterface? Explain why.What happens when your thread pool is completely exhausted?Why can creating too many threads make an application slower?What is Garbage Collection and how does it work?Is ConcurrentHashMap fail-fast?What happens to MDC/request context when work moves from one thread to another?What is EJB?How would you handle 10,000 concurrent requests in a Java backend?A thread is stuck in BLOCKED state. How will you identify and fix it?What is ClassLoader? Explain the delegation model.Difference between different types of EJBsWhat is the difference between WeakReference, SoftReference, and PhantomReference?How would you make a Java API thread-safe?When would you use TaskExecutor instead of simply creating your own ExecutorService?Why can an unbounded executor queue hide an overload problem until the application crashes?Why can a Java application be slow even when CPU usage is low?A table grows from thousands to millions of records — how would you maintain performance? Would database indexing help? How does an index work internally?How does the JIT compiler work?How would you size thread pools for CPU-bound versus I/O-bound workloads?Given a list of account transactions such as A:+100, B:+200, A:-50, C:+300, B:-100, A:+150, calculate the final balance for each account — explain approach, write code, time/space complexity, and solve using Java 8 features like Map.merge()Singleton PatternDouble-checked locking singleton without volatile: what can a second thread see?What improvements were introduced in Java 17 for Garbage Collection?ThreadLocal inside a thread pool: where is the leak, and what one line stops it?Builder Pattern vs Telescoping ConstructorHow would you handle a 2 GB file upload without loading the entire file into JVM heap?Two threads increment a shared long with no synchronized and no atomic. Give two different reasons the result is wrong.SOLID Principles overviewObject Header, Mark Word & Class PointerWhat is Code Cache and what happens when it fills up?Why volatile doesn't make count++ atomicWhat happens if a thread acquires a ReentrantLock and never calls unlock()? Why should unlock() sit in a finally block?What does the -XX:+PrintCompilation flag show you?Difference between lock(), tryLock() and lockInterruptibly().TLAB & Object AllocationYoung vs Old GenerationCan ReentrantLock be fair? What is the performance trade-off?What are the performance trade-offs between a 32-bit and 64-bit JVM?Escape Analysis & Scalar ReplacementRead-write lock starvation: why can a writer starve under continuous readers?What is an escaping reference, and what are the ways to prevent your internal mutable state from leaking to callers?What happens when a synchronized method calls another synchronized method on the same object?How do you tune the String Pool for an application creating millions of unique strings?GC Roots & Object ReachabilityWhat is String Deduplication in G1 GC and how is it different from the String Pool?False Sharing & Concurrent ProgrammingWhy is holding a lock while making a network call dangerous?Why should -Xms and -Xmx be set to the same value in production?How can a timeout on a lock stop one failure from blocking the whole application?Visibility & volatile — CPU caches, stale reads, and how volatile flush/invalidate worksWhat is lock escalation? Can excessive locking become a scalability bottleneck?What are the most important JVM flags you should know for production tuning?AtomicInteger & CAS — the compare-and-swap loop, lock-free counters, when to reach for LongAdderHow can nested locks across classes or services cause an unexpected deadlock?Why should you never call System.gc() in production code?Coding: find the smallest missing positive integer (>0) in an unsorted arrayHow can a non-thread-safe collection be used with Stream API?How would you prevent race conditions in a payment workflow?Why is Object.finalize() dangerous, and what should you use instead?What are the different types of thread pools in Java?Will synchronized in a Spring Boot service prevent duplicate orders across 3 instances? Can synchronized protect data stored in a database?What is Java Flight Recorder and how is it different from a heap dump?Why does a distributed application need a different locking approach than a single JVM? What is a distributed lock and when do you actually need one?What is code coverage and line coverage?Why is naive Java benchmarking (System.nanoTime() around a loop) misleading?How do you improve code coverage when build fails?Why is Redis-based distributed locking tricky? What happens if a JVM crashes while holding a distributed lock?What is JMH and what does it handle that a hand-rolled benchmark doesn't?Duplicate orders appear under high traffic though the code shows no obvious race. How do you investigate synchronization, DB constraints, isolation levels, idempotency and distributed concurrency?How do you verify a method is called twice in Mockito?What is a DirectByteBuffer, and why can it cause OutOfMemoryError even when heap usage looks fine?In which situations do you use PowerMock?Your Java process consumes 100% CPU — walk through diagnosing exactly which thread and method is responsible.Explain Java memory areas: Heap, Stack, Method Area and Program Counter (and Heap vs Stack).What is a BlockingQueue and where do you use it in real applications?What is garbage collection and how does it work? What is the purpose of finalize()?What does jcmd VM.native_memory reveal that a heap dump cannot?Explain class metadata in the context of Java class loading.What is ThreadLocal and where is it used?Your Spring Boot app gets OOM-killed in Kubernetes even though heap usage looks fine — how do you size JVM memory correctly for a container?What are the different types of OutOfMemoryError, and what does each one actually mean?What causes memory leaks in Java?Find the longest substring without repeating characters in JavaWhat tools would you reach for to monitor a Java application's performance in production?Write a Java program to find duplicate characters and their frequency in a stringWhy can OutOfMemoryError happen even when garbage collection is enabled?What is GraalVM and how does its Native Image differ from a standard JVM?Online gaming platform exercise: model Player, MatchResult, GameManager with WIN/LOSS/DRAW outcomes, record results from the player's perspective, and fix a bug in GameManager so provided tests passHow would you investigate unusually long GC pauses, including pauses that grow after a new release?Does the final keyword make an object immutable?How do you perform an effective code review?30 GB heap with a 10 ms pause budget: G1 or ZGC, and why?What is a memory leak in Java if Garbage Collection is automatic?When should you choose ArrayList over LinkedList (and vice versa)?How can unbounded caches cause memory problems?What are the two mandatory rules for overriding hashCode(), and what breaks if you only override equals()?How can listeners and callbacks cause memory leaks?When would you use TreeMap or LinkedHashMap over a plain HashMap?What is the difference between a memory leak and high memory usage?Why can naive string concatenation in a loop hurt performance, and did Java 9 change this?When can a Stream pipeline actually be slower than a plain for-loop?OutOfMemoryError vs StackOverflowError?How do you analyze a Heap Dump?Why should you never use double for financial calculations?Why does volatile guarantee visibility but not atomicity?What is a Dominator Tree?How does ConcurrentHashMap achieve thread safety without locking the entire map?What is a Retained Heap?Heap Dump vs Thread Dump?When would you choose LongAdder over AtomicInteger?How do you size a ThreadPoolExecutor differently for CPU-bound vs I/O-bound workloads?Does CompletableFuture create its own thread pool? Which pool does it use by default?What's the difference between thenApply(), thenCompose(), and thenCombine() in CompletableFuture?You receive a production thread dump with hundreds of BLOCKED threads — how do you identify the root cause?What is integration testing? How would you write an integration test involving a DB transaction?JUnit vs TestNG: why use TestNG and what are its benefits for automation?Selenium and TestNG experience: how did you structure test scenarios?What is parameterized testing in JUnit?Difference between @Mock and @Spy in JUnit.Find the minimum-length subarray whose sum equals a given target.Reverse a String without built-in methods.Find duplicate elements in an array.Check if a String is a palindrome.Implement an LRU Cache.Implement the Producer-Consumer problem.Find the first non-repeating character.Detect a cycle in a linked list.Find the top K frequent elements.
Open Core Java →2
3
4
5
6