Grokking Java Interview Questions
Answer the Java questions that interviews ask, from HashMap internals to virtual threads, with runnable code, follow-up questions, and predict-the-output exercises.

Course Overview
Java interviews ask how the language and its libraries work, not only how to use them. A typical conversation starts with a simple question, such as how a HashMap finds a key, and continues with follow-up questions until the mechanism is clear. This course is organized around those questions. Each lesson takes one topic and answers its main questions. Every answer starts with a short direct statement, explains the mechanism with real numbers from the JDK, and names a common wrong answer. Each question is marked Junior, Mid-level, or Senior, and has follow-up questions with folded answers, so you can try them before you read. Many answers include a small program that you can run. The course covers the JVM, the language core, class design, generics, collections, exceptions, streams, concurrency, memory and garbage collection, modern Java up to Java 25, production topics such as JDBC and testing, and Spring. Most lessons end with a program whose output you predict before you run it. Later chapters practice code reading and coding tasks, and the course closes with mock rounds for three levels and a final exam. It suits engineers who know Java syntax and want to explain how Java works with confidence.
What you'll learn in Grokking Java Interview Questions
- Answer each Java question with a direct statement, then explain the mechanism behind it with numbers and code.
- Get the language core right: pass by value, equals and hashCode, the string pool, and initialization order.
- Reason about generics: type erasure, bridge methods, bounded types, wildcards, and the PECS rule.
- Handle exceptions and resources correctly, including a return inside finally and suppressed exceptions.
- Explain race conditions, synchronized, volatile, the Java Memory Model, deadlocks, and interruption.
- Understand garbage collection, G1 and ZGC, reference types, memory leaks, heap dumps, and thread dumps.
- Answer production questions on JDBC, transactions, serialization, reflection, testing, and Spring internals.
- Check yourself with chapter assessments, mock rounds for junior, mid-level, and senior levels, and a final exam.
- Explain the JVM: bytecode, the JIT compiler, class loading and initialization, and the Java release cycle.
- Compare abstract classes and interfaces, and choose enums, records, sealed types, and composition with reasons.
- Describe how ArrayList, HashMap, TreeMap, and PriorityQueue work inside, including resizing and tree buckets.
- Use lambdas, streams, collectors, Optional, and parallel streams, and know when a plain loop is better.
- Work with thread pools, CompletableFuture, locks, atomic variables, ConcurrentHashMap, and virtual threads.
- Know what changed from Java 8 to Java 25, including records, pattern matching, modules, and virtual threads.
- Practice code reading, bug finding, and coding tasks such as an LRU cache, a blocking queue, and a rate limiter.
Course Content
Language Core
Primitive Types and Wrapper Classes
Pass by Value in Java
The equals and hashCode Contract
Strings, the String Pool, and Immutability
StringBuilder, StringBuffer, and Concatenation
static, final, and Initialization Order
Access Modifiers and Packages
Copying Objects
Chapter Assessment: Language Core
Class Design
Abstract Classes vs Interfaces
Overriding and Overloading
Polymorphism and Dynamic Dispatch
Composition vs Inheritance
Nested, Inner, and Anonymous Classes
Enums
Records
Sealed Classes and Immutable Class Design
Chapter Assessment: Class Design
Generics
Type Erasure
Bounded Types
Wildcards and the PECS Rule
Generic Methods and Type Inference
Limits of Generics
Chapter Assessment: Generics
Collections Internals
ArrayList Internals and Growth
ArrayList vs LinkedList
How HashMap Stores and Finds Entries
HashMap Resizing, Treeification, and Key Design
HashSet, LinkedHashMap, and an LRU Cache
TreeMap, TreeSet, and Ordering
Queues, Deques, and PriorityQueue
Iterators and ConcurrentModificationException
Unmodifiable, Immutable, and Synchronized Collections
Chapter Assessment: Collections Internals
Exceptions and Resources
Checked and Unchecked Exceptions
try, catch, finally, and Return Values
try with resources
Designing Custom Exceptions
Chapter Assessment: Exceptions and Resources
Lambdas and Streams
Lambdas and Functional Interfaces
Method References and Variable Capture
Stream Pipelines and Lazy Evaluation
map, flatMap, filter, and reduce
Collectors and Grouping
Optional
Parallel Streams
Chapter Assessment: Lambdas and Streams
Concurrency Fundamentals
Threads and the Thread Lifecycle
Race Conditions and synchronized
The Java Memory Model and volatile
wait, notify, and Guarded Blocks
Deadlock, Livelock, and Starvation
Thread Safety and Immutability
ThreadLocal
Interruption and Shutdown
Chapter Assessment: Concurrency Fundamentals
Modern Concurrency
Executors and Thread Pools
Future and CompletableFuture
ReentrantLock and ReadWriteLock
Atomic Variables and Compare and Swap
ConcurrentHashMap and Concurrent Collections
CountDownLatch, Semaphore, and CyclicBarrier
The Fork Join Pool
Virtual Threads and Structured Concurrency
Chapter Assessment: Modern Concurrency
Memory and Garbage Collection
Stack, Heap, and Metaspace
How Garbage Collection Finds Unused Objects
Generations and Collectors: G1, ZGC, and Others
Strong, Soft, Weak, and Phantom References
Memory Leaks in Java
Reading a Heap Dump and a Thread Dump
JVM Flags and GC Tuning
Chapter Assessment: Memory and Garbage Collection
Modern Java Features
var, Text Blocks, and Switch Expressions
Pattern Matching
Record Patterns
Modules
What Changed From Java 8 to Java 25
Chapter Assessment: Modern Java Features
Java in Production
JDBC and Prepared Statements
Transactions and Isolation Levels
Serialization
Reflection
Annotations
Unit Testing With JUnit and Mockito
Design Patterns in the JDK
Dates, Time, and BigDecimal
Chapter Assessment: Java in Production
Spring Essentials
Inversion of Control and Dependency Injection
Bean Scopes and Lifecycle
Spring Boot Auto Configuration
Proxies, AOP, and Transactional
Spring MVC Request Handling
Spring Data JPA and the N Plus One Problem
Chapter Assessment: Spring Essentials
Code Reading and Coding Rounds
Predict the Output: Strings and Wrappers
Predict the Output: Inheritance and Initialization
Predict the Output: Collections and Streams
Find the Bug: Concurrency
Implement an LRU Cache
Implement a Thread Safe Singleton
Implement a Blocking Queue
Implement a Rate Limiter
Chapter Assessment: Code Reading and Coding Rounds
Mock Rounds
Junior Mock Round
Mid Level Mock Round
Senior Mock Round
Final Exam
What people say about our courses






About the Author

Arslan Ahmad
Industry Expertise & Leadership
Arslan Ahmad is the lead author of Grokking Java Interview Questions. As the founder of Design Gurus and a former FAANG hiring manager, he has worked at industry giants like Facebook (now Meta) and Microsoft.
He has conducted hundreds of system design interviews, giving him unique insight into what top tech companies look for in candidates.
The course also incorporates expertise from senior engineers at Google, Meta, Amazon, Microsoft, and Uber, ensuring you learn system design best practices from professionals who have built and scaled real-world systems.
500+
Interviews Conducted
10k+
Students Taught
Related Courses
$48
$48
$48
FAQs
What is Grokking Java Interview Questions?
It is a written course built around the questions that Java interviews ask. Each lesson takes one topic, answers its main questions with a direct statement, and then explains the mechanism with real numbers from the JDK and code. It covers the JVM, the language core, collections, concurrency, memory, modern Java, production topics, and Spring.
Who is this course for?
It is for engineers who already write Java and are preparing for an interview, from new graduates to senior engineers. It also suits a working developer who uses HashMap, streams, or @Transactional every day and wants to be able to explain how they work.
What do I need to know before I start?
You need Java syntax, classes, and basic use of collections. If you are new to Java, start with Grokking Java Basics and Grokking Java Intermediate, and return to this course when you prepare for interviews.
How is this different from a list of Java interview questions?
A list gives you an answer to memorize. This course explains why the answer is true, so that you can also answer the question that comes next. Every main question comes with a common wrong answer and with follow-up questions that go one step deeper, and many answers include a program that proves the claim.
Does it cover junior, mid-level, and senior questions?
Yes. Every main question is marked Junior, Mid-level, or Senior, so you can read only your level when time is short. The course ends with a mock round for each of the three levels, with model answers and a scoring table that points to the lessons to read again.
Which Java versions does it cover?
It covers Java 8 to Java 25. The programs you run use Java 17 syntax. Features of Java 21, such as virtual threads, pattern matching for switch, and record patterns, are shown with real output from Java 21. Changes in later releases are described from the official documentation of each feature.
Can I run the code in the browser?
Yes. Many answers include a short Java program that runs in the course player with the Run button, and you can change it and run it again. Code that needs a database, a test framework, or Spring is shown read-only together with the real output it produced.
Does it cover Java concurrency?
Yes, in two parts. The first covers threads, race conditions, synchronized, the Java Memory Model and volatile, wait and notify, deadlocks, ThreadLocal, and interruption. The second covers thread pools, CompletableFuture, explicit locks, atomic variables, ConcurrentHashMap, synchronizers, the fork join pool, and virtual threads.
Does it cover Spring and Spring Boot?
Yes, at the depth that interviews ask. It explains dependency injection, bean scopes and the bean lifecycle, auto-configuration, proxies and @Transactional, request handling in Spring MVC, and the N plus one problem in Spring Data JPA. For a full course on building services with Spring, see Grokking Spring Boot.
Does it cover data structures and algorithms?
No. It covers the Java side of a coding round: reading code and predicting its output, finding concurrency bugs, and writing an LRU cache, a thread-safe singleton, a blocking queue, and a rate limiter. For algorithm patterns, use Grokking the Coding Interview.
Is there any practice, or is it only reading?
There is practice in every part. Follow-up questions have folded answers, so you can answer first and then compare. Most lessons end with a program whose output you predict before you run it. Every chapter except the last one ends with an adaptive assessment that draws a fresh set of questions on every attempt, and the last chapter holds the mock rounds and a final exam.
How should I use the course when my interview is one week away?
Read the questions at your level first, and use the bold first sentence of each answer as the short answer. Then take the mock round for your level, and use its scoring table to choose the lessons to read in full. If you must choose, start with the chapters on the language core, collections, and concurrency.