Core Java
The Java fundamentals every interview starts with — OOP, Strings & Collections, Java 8+ features, exception handling, multithreading, JVM internals, and the DSA problems that show up alongside them.
Inner Classes
What are the different types of inner classes in Java — member, static nested, local, and anonymous?
intermediateTests whether you know all four flavors and what specifically distinguishes each one's scope and use case.
What is the difference between a static nested class and a (non-static) inner class in Java?
intermediateTests whether you know a static nested class doesn't hold an implicit reference to an instance of the outer class, unlike a regular inner class.
What is a local inner class in Java? What are the rules around accessing variables from its enclosing method?
intermediateTests whether you know a local inner class can only capture effectively final local variables from its enclosing scope.
What are anonymous inner classes in Java, and what are their restrictions compared to named classes?
intermediateTests whether you know when this one-off, no-name class syntax is appropriate versus when a lambda or named class fits better.
JVM Internals & Memory
What is the difference between Minor GC, Major GC, and Full GC?
intermediateTests whether you know exactly which memory regions each GC type actually sweeps.
What is an OutOfMemoryError vs StackOverflowError?
intermediateTests whether you know these are triggered by two completely different memory regions filling up.
G1 GC vs ZGC vs Shenandoah — when would you choose each?
advancedTests whether you know the pause-time and throughput tradeoffs across modern collectors, not just their names.
Heap keeps growing even after a Full GC runs. How do you debug it?
advancedTests whether you recognize this as the classic memory-leak signature and know the heap-dump workflow to isolate it.
Production throws OutOfMemoryError: Metaspace. What could cause it?
advancedTests whether you know Metaspace exhaustion usually points to classloader leaks, not regular object allocation.
Java heap is stable, but overall process memory keeps growing. Why?
advancedTests whether you know to look past the heap entirely — direct ByteBuffers, Netty off-heap memory, or JNI leaks.
Your application pauses frequently, but GC logs look completely normal. What's going on?
advancedTests whether you know JVM safepoints (biased lock revocation, deoptimization) can freeze threads independently of GC.
What is Escape Analysis? Why is it useful?
advancedTests whether you know the JIT can allocate objects on the stack instead of the heap when it proves they never escape a method.
What is the Parent Delegation Model in class loading, and why is it important?
intermediateTests whether you know why a class request always goes up the classloader hierarchy first, and what that prevents.
How do you capture and analyze a heap dump using Eclipse MAT — what do you actually look for?
advancedTests whether you know the practical workflow: dominator tree, retained size, and finding the actual leak suspect.
What is TLAB (Thread Local Allocation Buffer) and how does it improve allocation performance?
advancedTests whether you know how the JVM avoids lock contention on every single object allocation.
What is GC ergonomics and how does the JVM auto-tune GC settings?
intermediateTests whether you know the JVM picks sensible defaults based on hardware and heap size without any flags at all.
What are the different memory areas in JVM?
beginnerTests whether you know the heap, stack, metaspace, and PC register layout and what lives where.
What is Garbage Collection and how does it work?
intermediateTests whether you understand generational GC, reachability, and why Java doesn't need manual memory management.
What is ClassLoader? Explain the delegation model.
intermediateTests whether you know why a class request is always delegated upward first, and what that prevents.
What is the difference between WeakReference, SoftReference, and PhantomReference?
advancedTests whether you know these three reference types and how each affects when the GC is allowed to reclaim an object.
How does the JIT compiler work?
advancedTests whether you understand how the JVM detects hot code paths and compiles them to native machine code at runtime.
Java Basics & OOP
What is the difference between JDK, JRE, and JVM?
beginnerTests whether you understand the three nested layers of the Java platform and what each one is actually responsible for.
Explain the 4 pillars of OOP with real-world examples.
beginnerChecks whether you can explain encapsulation, abstraction, inheritance, and polymorphism with concrete examples, not just definitions.
What is the difference between == and .equals() in Java?
beginnerTests your understanding of reference equality versus logical equality, and where each one silently trips people up.
What is method overloading vs method overriding?
beginnerTests whether you know compile-time vs runtime polymorphism and the rules that govern each.
What is the difference between abstract class and interface?
beginnerTests whether you know when to use each, especially after Java 8 added default and static methods to interfaces.
Explain the 'static' keyword — static variable, method, block, class.
beginnerTests whether you understand what 'belongs to the class, not the instance' actually means in memory and execution order.
What is the difference between pass-by-value and pass-by-reference in Java?
beginnerA classic trick question — tests whether you know Java is always pass-by-value, even for objects, and why that still confuses people.
What is autoboxing and unboxing?
beginnerTests whether you know how Java silently converts between primitives and wrapper classes, and where that costs performance.
What is the diamond problem and how does Java 8 solve it with default methods?
advancedTests whether you understand multiple inheritance ambiguity and the specific resolution rules Java applies for default methods.
Explain how 'instanceof' works and what pattern matching for instanceof (Java 16) does.
advancedTests whether you know the classic instanceof check plus the newer syntax that eliminates the redundant cast afterward.
File I/O & NIO
What is the difference between byte streams and character streams in Java I/O — when do you use InputStream/OutputStream vs Reader/Writer?
intermediateTests whether you know binary data needs byte streams while text data is better handled by character-aware Reader/Writer classes.
What is the difference between FileReader and BufferedReader, and why does wrapping one in the other improve performance?
beginnerTests whether you know buffering reduces the number of expensive underlying I/O calls by reading in larger chunks.
What is the difference between java.io and java.nio? What does NIO's non-blocking, buffer-based model actually change?
advancedTests whether you know NIO's channel/buffer model and selectors enable non-blocking I/O that classic java.io can't do.
Why should file handling code always use try-with-resources instead of manually closing streams in a finally block?
intermediateTests whether you know try-with-resources guarantees close() is called correctly even when multiple exceptions occur, which manual finally blocks often get wrong.
Enums
How do Java enums work internally? What do values(), ordinal(), and valueOf() actually do?
intermediateTests whether you know an enum is really a special class with a fixed set of singleton instances, not just a list of named integers.
Can a Java enum have constructors, fields, and methods? Can each enum constant override a method differently?
intermediateTests whether you know enums are full classes that can carry state and even constant-specific method bodies.
Why are enums a good fit for switch statements and as HashMap/EnumMap keys?
intermediateTests whether you know enums give you type safety and namespace clarity that plain int or String constants don't.
String & StringBuilder
What is String immutability? Why is String immutable in Java?
beginnerTests whether you know the actual design reasons (security, caching, thread safety) behind one of Java's most quoted facts.
What is the String constant pool?
beginnerTests whether you understand where string literals actually live in memory and why that affects == comparisons.
What is the difference between String, StringBuilder, and StringBuffer?
beginnerTests whether you know the mutability and thread-safety tradeoffs behind these three near-identical-looking classes.
Find the longest palindromic substring.
intermediateA classic string DSA problem testing whether you can move from brute force to an efficient expand-around-center or DP approach.
Minimum window substring — find the smallest window in S containing all characters of T.
advancedTests whether you can apply the sliding-window technique correctly to a genuinely tricky two-pointer problem.
Multithreading & Concurrency
Why do Virtual Threads become pinned and lose scalability?
advancedTests whether you know synchronized blocks and native calls can pin a virtual thread to its carrier thread.
What is structured concurrency in Java 21+ and why is it better than raw CompletableFuture chains?
advancedTests whether you know how it ties a group of subtasks' lifetimes together for cleaner cancellation and error handling.
Why are exceptions inside CompletableFuture chains often missed silently?
advancedTests whether you know an unhandled exception in a chain just completes the future exceptionally, with nothing logged unless you check.
ConcurrentHashMap is thread-safe, yet race conditions can still exist in code that uses it. Why?
advancedTests whether you know thread-safety of individual operations doesn't make compound check-then-act sequences atomic.
Why can increasing the thread pool size actually reduce application performance?
advancedTests whether you know excessive threads can increase context-switching overhead and contention beyond a certain point.
What is the difference between synchronized, ReentrantLock, and StampedLock?
advancedTests whether you know the tradeoffs in fairness, interruptibility, and read/write optimization across the three.
What is the difference between CountDownLatch, CyclicBarrier, and Semaphore?
advancedTests whether you know these three synchronization tools solve genuinely different coordination problems.
How does ForkJoinPool differ from a regular ThreadPoolExecutor?
advancedTests whether you know work-stealing is what makes ForkJoinPool efficient for divide-and-conquer tasks specifically.
What happens when you submit too many tasks to a ThreadPoolExecutor — what are the rejection policies?
advancedTests whether you know the four built-in RejectedExecutionHandler strategies and when each is appropriate.
What is a race condition and how is it different from a data race?
advancedTests whether you know these overlapping-sounding terms actually describe two distinct classes of concurrency bug.
A ThreadLocal variable in your app is causing a memory leak. How does that happen, and how do you fix it?
advancedTests whether you know pooled threads never die, so a ThreadLocal never cleared keeps leaking across every reused thread.
What is the difference between a Thread and a Process?
beginnerTests whether you understand shared vs isolated memory space and why threads are cheaper to create.
What is the difference between wait(), notify(), and notifyAll()?
intermediateTests whether you understand Java's low-level thread coordination primitives and the monitor lock they require.
What is a deadlock? How can you detect and prevent it?
intermediateTests whether you know the four necessary conditions for deadlock and practical strategies to avoid them.
What is the volatile keyword in Java?
intermediateTests whether you know volatile guarantees visibility, not atomicity — one of the most commonly misunderstood keywords.
What is ExecutorService? How is it better than creating raw threads?
intermediateTests whether you know why managed thread pools beat manually creating and managing Thread objects in production code.
What is a thread-safe Singleton? Implement double-checked locking.
advancedTests whether you can correctly write the volatile + double-checked-locking pattern, a classic concurrency coding question.
What is the Java Memory Model (JMM)? Explain happens-before.
advancedTests whether you understand the formal rules that govern visibility and ordering across threads — deep concurrency territory.
What is CompletableFuture? How does it differ from Future?
advancedTests whether you know how to chain and combine async operations rather than blocking with Future.get().
Arrays & Matrices
What is the difference between Array and ArrayList?
beginnerTests whether you know the fixed-size-vs-dynamic and primitive-vs-object tradeoffs between the two.
Find the maximum subarray sum (Kadane's algorithm).
intermediateTests whether you know the classic O(n) dynamic programming trick, not just a brute-force O(n²) scan.
Sort an array of 0s, 1s, and 2s in a single pass (Dutch National Flag).
intermediateTests whether you can sort in a single O(n) pass with three pointers instead of a generic sort or two passes.
Trapping rainwater problem — compute how much water can be trapped.
advancedA well-known hard array problem testing two-pointer or prefix-max/suffix-max thinking under a tricky constraint.
Find the longest increasing subsequence (LIS).
advancedTests whether you know both the O(n²) DP solution and the O(n log n) patience-sorting-based approach.
Collections Framework
Explain the Collections hierarchy — List, Set, Map, Queue.
beginnerTests whether you have a clear mental map of Java's core collection interfaces and how they relate to each other.
How does HashMap work internally? (hashing, buckets, collision)
intermediateOne of the most-asked Java questions — tests whether you actually understand hashing, bucket placement, and collision resolution, not just usage.
What is the difference between HashMap and Hashtable?
intermediateTests whether you know the thread-safety, null-key, and performance differences between these two legacy-adjacent classes.
A HashMap has millions of entries and suddenly becomes slow. How would you investigate?
advancedTests whether you know to check hashCode() quality, load factor, and whether entries are treeifying due to collisions.
How does ConcurrentHashMap differ from HashMap?
intermediateTests whether you understand segment/bucket-level locking and why it beats simply synchronizing a whole HashMap.
What is fail-fast vs fail-safe iterator?
intermediateTests whether you know why ConcurrentModificationException happens and which collections avoid it, and how.
You insert a mutable object as a HashMap key and later modify it. What can go wrong?
advancedTests whether you know a changed hashCode() after insertion makes the entry effectively unfindable at its original bucket.
Your CopyOnWriteArrayList is creating high memory usage and GC pressure. Why?
advancedTests whether you know every single write copies the entire underlying array, which is brutal for write-heavy or large lists.
Implement an LRU cache using LinkedHashMap.
advancedA very common coding-round question testing whether you know LinkedHashMap's access-order mode and removeEldestEntry hook.
What happens when HashMap capacity exceeds load factor? Explain rehashing.
advancedTests whether you understand the resize trigger, the doubling behavior, and why rehashing is expensive.
A ConcurrentModificationException occurs in a single-threaded application. How is that possible?
advancedTests whether you know this exception is about structural modification during iteration, not literally about concurrent threads.
You're reviewing production code using Collections.synchronizedMap(). Would you keep it or replace it? What factors decide?
advancedTests whether you can weigh whole-map locking against ConcurrentHashMap's finer-grained concurrency for the actual access pattern.
Why can a poor hashCode() implementation destroy HashMap performance?
advancedTests whether you know a constant or low-quality hashCode collapses lookups from O(1) toward O(n) by funneling everything into one bucket.
Two threads call computeIfAbsent() for the same key on a ConcurrentHashMap at the same time. What behavior do you expect?
advancedTests whether you know ConcurrentHashMap guarantees the mapping function runs atomically per key, avoiding duplicate computation.
What is EnumMap and why is it more performant than HashMap for enum keys?
intermediateTests whether you know EnumMap uses ordinal-based array indexing instead of general-purpose hashing.
You need the top 10 most frequent items out of millions of events. Which collections would you combine to solve this efficiently?
advancedTests whether you know to pair a frequency HashMap with a bounded PriorityQueue instead of sorting everything.
A cache should automatically release entries when their keys are no longer strongly referenced elsewhere. What would you use?
advancedTests whether you know WeakHashMap lets the garbage collector reclaim entries whose keys have become otherwise unreachable.
Java 8+ Features
What are the key features introduced in Java 8?
beginnerTests whether you can name and briefly explain lambdas, streams, Optional, and the new Date/Time API.
What is a functional interface? Can you write a custom one?
beginnerTests whether you understand the single-abstract-method rule that makes lambda expressions possible.
What is the difference between map() and flatMap() in Streams?
intermediateTests whether you understand when a stream operation needs to flatten nested structures, not just transform elements.
What is the Optional class? How does it prevent NullPointerException?
beginnerTests whether you know how to use Optional correctly, and the common anti-patterns that misuse it.
What is the difference between lazy and eager evaluation in Streams? Explain with an example.
advancedTests whether you understand that intermediate operations don't execute until a terminal operation triggers the pipeline.
Exception Handling
What is the difference between checked and unchecked exceptions?
beginnerTests whether you know which exceptions the compiler forces you to handle and why that distinction exists.
What is try-with-resources? How does it differ from traditional try-catch-finally?
intermediateTests whether you know how AutoCloseable resources get closed automatically, and in what order during suppressed exceptions.
How do you create a custom exception? Give checked and unchecked examples.
intermediateTests whether you can design exception classes correctly and know when each type is the right choice.
What is exception chaining?
advancedTests whether you know how to preserve the original cause when wrapping and rethrowing a different exception type.
What is the difference between ClassNotFoundException and NoClassDefFoundError?
advancedTests whether you know these are thrown at different times for different reasons, despite sounding like the same problem.
Modern Java (11-25)
Are Java Records truly immutable? What are their limitations?
intermediateTests whether you know records give you shallow immutability for their own fields, not deep immutability of referenced objects.
What are Sealed Classes in Java 17 — how do they enforce domain modeling?
intermediateTests whether you know sealed types let you declare an exhaustive, closed set of permitted subtypes at compile time.
What is Pattern Matching for switch (Java 21) and how does it improve type-safe branching?
intermediateTests whether you know how it eliminates the manual instanceof-and-cast boilerplate switch statements used to require.
What are Sequenced Collections in Java 21?
intermediateTests whether you know this new interface finally gives a consistent way to access first/last elements across ordered collection types.
How does Java 21's virtual thread implementation handle blocking I/O internally — what is carrier thread pinning?
advancedTests whether you understand the mechanism that lets thousands of virtual threads share a small pool of OS carrier threads.
What is the difference between var (Java 10) and explicitly typed declarations — when does var hurt readability?
intermediateTests whether you know var is fine when the type is obvious from context, but can obscure intent when it isn't.
Java 25 Compact Object Headers (JEP 519) — what does it mean for production workloads?
advancedTests whether you're current on recent JVM changes and know what shrinking object headers actually saves in practice.
DSA — Problem-Solving Patterns
What is the Sliding Window pattern in DSA, and what class of problems does it solve efficiently?
intermediateTests whether you can recognize when a shrinking/growing window beats a brute-force nested loop.
What is the two-pointer pattern? Give an example problem where it turns an O(n²) solution into O(n).
intermediateTests whether you know how converging pointers from both ends of a sorted structure eliminate redundant comparisons.
What is the fast & slow pointers pattern? How does it detect a cycle in a linked list?
intermediateTests whether you know Floyd's algorithm and why two pointers moving at different speeds must eventually meet in a cycle.
What is the merge intervals pattern? Walk through merging a list of overlapping intervals.
intermediateTests whether you know to sort by start time first, then merge in a single linear pass.
What is the Top K Elements pattern using a heap, and why is it more efficient than sorting the entire dataset?
advancedTests whether you know a bounded heap gets you the top K in O(n log k) instead of paying for a full O(n log n) sort.
What is the 0/1 Knapsack dynamic programming pattern, and what other problems share its structure?
advancedTests whether you can recognize the include-or-exclude decision structure that generalizes to many DP problems.
What is the topological sort graph pattern? How does it apply to a course-scheduling / build-order problem?
advancedTests whether you know how to order nodes in a DAG so every dependency is processed before what depends on it.
Find the Kth largest element in a stream of numbers, where new numbers keep arriving.
advancedTests whether you know to maintain a fixed-size min-heap instead of re-sorting on every new element.
Implement an LFU (Least Frequently Used) Cache with O(1) get and put.
advancedTests whether you can design a harder variant of LRU that also tracks access frequency, not just recency.
Find the median from a data stream — numbers keep arriving one at a time, and you must return the median at any point.
advancedTests whether you know the two-heap technique (a max-heap and a min-heap balanced against each other) for this classic problem.
Solve the Word Ladder problem — find the shortest transformation sequence from one word to another, changing one letter at a time.
advancedTests whether you know to model this as a graph shortest-path problem and solve it with BFS.
DSA — Lists, Stacks & Queues
Reverse a Singly Linked List
intermediateOne of the most common coding-round openers — tests whether you can manipulate pointers correctly without losing the list.
Detect a loop in a Linked List
intermediateTests whether you know Floyd's cycle detection (slow/fast pointer) technique.
LRU Cache implementation
advancedTests whether you can combine a hash map and a doubly linked list to get O(1) get/put with eviction.
DSA — Trees & Graphs
Binary Tree Traversals
intermediateTests whether you can implement preorder, inorder, postorder, and level-order traversal, iteratively and recursively.
Validate a Binary Search Tree (BST)
intermediateTests whether you know the common mistake of only checking immediate children instead of the full valid range.
Dijkstra's Shortest Path Algorithm
advancedTests whether you can implement the classic priority-queue-based shortest path algorithm and explain its greedy correctness.
Topological Sort
advancedTests whether you know how to order a DAG's nodes using DFS-based or Kahn's BFS-based approach.
Design Patterns & SOLID
Singleton Pattern
beginnerTests whether you can implement Singleton correctly and know the ways it can accidentally be broken.
Builder Pattern vs Telescoping Constructor
beginnerTests whether you know when a growing list of constructor parameters should become a Builder instead.
SOLID Principles overview
intermediateTests whether you can name and briefly explain all 5 SOLID principles with a one-line example each.