Learning path · 57 lessons · 7 topics
☕ Java interview preparation
Core Java to Java 21: collections, OOP, JVM internals, streams and concurrency.
Java is still the most common language in backend interviews, and interviewers go deep: how a HashMap works inside, what the JVM does with memory, how threads share data safely, and which modern features (records, sealed types, virtual threads) you actually use.
Start with core Java and OOP, then move to the JVM and concurrency, and finish with the Java 8, 17 and 21 features that show you write modern code. Every lesson has runnable examples and the follow-up questions interviewers ask next.
What you will learn
- Collections internals, equals/hashCode, immutability and generics
- JVM memory, garbage collection, class loading
- Threads, locks, executors, CompletableFuture and virtual threads
- Lambdas, streams, records, sealed classes, pattern matching
Topics
Roadmap: beginner to advanced
-
1
Intermediate Intermediate stage
Working knowledge: how things behave in real projects and the trade-offs you make.
Java
- Explain the equals() and hashCode() contract. What breaks if you get it wrong?
- Why is String immutable in Java, and how does the String pool work?
- How do you design an immutable class? What about one that contains a mutable object?
- How do you choose between ArrayList, LinkedList, HashMap, LinkedHashMap and TreeMap?
- Abstract class vs interface in modern Java: when do you use each?
- How do you design exception handling in a layered Java application?
- How do Java Streams work internally, and what are the common pitfalls?
- Explain functional interfaces, lambdas, method references and how to use Optional well.
- Which features from Java 8 to Java 21 have you used in production, and why do they matter?
Java 8
- Java 8: Count word frequencies in a text. How many ways can you solve it, from feasible to optimal?
- Java 8: Find duplicate elements in a list. Show every approach from brute force to optimal.
- Java 8: Find the first non-repeating character in a string. Compare all approaches.
- Java 8: Sort a list of employees by several fields. Show the evolution from anonymous Comparator to Comparator.comparing.
- Java 8: Replace nested null checks with Optional. Show the alternatives and the anti-patterns.
- Java 8: How do default and static interface methods let you evolve an API? Show the alternatives.
- Java 8: Date and time problems with java.time (age, business days, time zones). Compare legacy and modern solutions.
- Java 8: Compute revenue per product from orders (flatMap, groupingBy, reduce). Compare loop and stream solutions.
Java 17
- Java 17: Use records for value objects and composite keys. Compare POJO, string keys, nested maps and records.
- Java 17: Switch expressions. Compare if-else, classic switch, map lookups, switch expressions and enums.
- Java 17: Build multi-line SQL and JSON with text blocks. Compare concatenation, StringBuilder and text blocks safely.
- Java 17: Immutable and unmodifiable collections. Compare Arrays.asList, unmodifiableList, List.of, List.copyOf and Stream.toList.
- Java 17: Call a REST API with the Java 11 HttpClient. Compare HttpURLConnection, sync, async and retrying clients.
Java 21
Java Streams
- Java 8 Streams interview problems on an Employee list.
- Java 8 Streams interview problems on strings and numbers.
- Sort a HashMap by its values. Compare a list of entries, TreeMap with a comparator, streams into a LinkedHashMap and Java 21 sequenced maps.
- Convert a list of objects to a Map, handling duplicate keys. Compare loops, toMap, toMap with merge, and groupingBy.
Concurrency
-
2
Advanced Advanced stage
Senior depth: internals, scale, failure modes and design decisions.
Java
- How does HashMap work internally in Java 8 and later?
- Explain generics, type erasure, wildcards and the PECS rule.
- Which design patterns and SOLID principles do you apply in production Java code?
Advanced Java
- Explain the Java Memory Model, happens-before and the volatile keyword.
- Compare synchronized, ReentrantLock, ReadWriteLock and StampedLock.
- How does ConcurrentHashMap work internally in Java 8+?
- How do you configure ThreadPoolExecutor correctly for production?
- How do you compose asynchronous work with CompletableFuture, including errors and timeouts?
- What are virtual threads, when should you use them and what are the pitfalls?
- Describe the JVM memory areas and the class-loading process.
- How do G1, ZGC and Parallel GC differ, and how do you tune garbage collection?
- How do you troubleshoot high CPU, a memory leak or a hung application in production?
- Explain wait/notify, BlockingQueue and the main synchronizers (CountDownLatch, CyclicBarrier, Semaphore).
Java 8
- Java 8: Call three slow services and combine the results. Compare sequential, Future and CompletableFuture solutions.
- Java 8: Find the second highest salary in each department. Show sorting, streams and the optimal single pass.
Java 17
- Java 17: Sealed classes and pattern matching for instanceof. Compare instanceof casts, polymorphism, the visitor pattern and sealed types.
- Java 17: Sum all numbers in a nested, mixed-type structure. Compare casts, pattern matching, streams and an iterative stack.
- Java 17: Parse a log section with the Java 9 to 17 Stream and String APIs. Compare loops, Java 8 streams and modern streams.
Java 21
- Java 21: Run 1,000 blocking I/O tasks concurrently. Compare sequential, thread pools, CompletableFuture and virtual threads.
- Java 21: Evaluate and simplify an expression tree. Compare instanceof chains, polymorphism, the visitor and pattern matching for switch with record patterns.
- Java 21: Model an order lifecycle as a state machine. Compare string states, polymorphic states and pattern matching on (state, event) pairs.
- Java 21: Fan out to several suppliers with a timeout and pick the cheapest quote. Compare CompletableFuture, invokeAll on virtual threads and structured concurrency.
- Java 21: Build a thread-safe request counter under 100,000 virtual threads. Compare unsynchronised, synchronized, ReentrantLock, AtomicLong and LongAdder.
- Java 21: Handle validation errors without exceptions for control flow. Compare exceptions, Optional and a sealed Result type with pattern matching.
- Java 21: Migrate a legacy report method from Java 7 to Java 8, 17 and 21, step by step.
Concurrency