Skip to content
Java interview handbook · PDF ebook

Crack the Java round with 100 questions that get asked.

Core Java, OOP, Collections and HashMap internals, Streams, multithreading, the JVM and Java 17 / 21. Every answer explains what happens underneath and the follow-up the interviewer asks next.

100
questions
12
chapters
3
difficulty levels
8→21
Java versions
₹199₹39950% off
  • Secure checkout via Razorpay
  • Digital PDF ebook
  • Read on phone, tablet or laptop
Master Java Interviews ebook coverPDF ebook
At a glance

What is the Java Interview Handbook?

The Java Interview Handbook is a digital PDF ebook by Target Trek with 100 Java interview questions and answers in 12 chapters, from Java fundamentals and OOP to the Collections Framework, the Stream API, multithreading, JVM memory and modern Java 17 and 21. Every answer explains the internals and the follow-up an interviewer is likely to ask.

  • Core Java
  • OOP
  • Strings
  • Collections
  • HashMap internals
  • Generics
  • Stream API
  • Lambdas
  • Multithreading
  • Concurrency
  • JVM
  • Garbage collection
  • Records
  • Sealed classes
  • Virtual threads
Format
Digital PDF ebook
Questions
100, with answers
Chapters
12 · Q1 to Q100
Levels
Beginner → Advanced
Java versions
Java 8, 17 and 21
Best for
Freshers to SDE-2
Reads on
Phone, tablet, laptop
Publisher
Target Trek
Why this book

Stop memorising. Start explaining.

Interviewers rarely stop at the definition. They ask why, then what happens if. This book prepares you for the second and third question, not just the first.

  • Without a plan: Reading random blog posts for every Java topic

    With this handbook: 100 curated questions in one structured handbook

  • Without a plan: Memorising definitions you cannot explain

    With this handbook: Answers with the internals, an example and the likely follow-up

  • Without a plan: Freezing on output and tricky-behaviour questions

    With this handbook: Code-output chapters that train you to trace Java line by line

  • Without a plan: Skipping concurrency and the JVM because they feel hard

    With this handbook: Dedicated chapters on threads, locks, memory and garbage collection

What makes it different

  • Interview-focused

    100 questions picked from real Java rounds and ordered from basics to internals, so you revise what actually gets asked.

  • Practical Java code

    Short snippets, output puzzles and full implementations such as an LRU cache and a thread-safe counter.

  • Internals, not definitions

    How HashMap, the String pool, the JVM heap, garbage collectors and locks really work underneath.

  • Fast revision

    Chapters you can finish in one sitting and a 7-day plan for the week before your interview.

Choose your book

The Java backend interview series

Core Java is the first round, Spring Boot is the backend round and LLD is the design round. Each book stands alone, and together they cover a full Java SDE interview loop.

This page
Core Java · 100 Q&A

Master Java Interviews

Core Java, OOP, Strings, Collections and HashMap internals, Streams, multithreading, JVM and modern Java 17 / 21.

  • 100 questions in 12 chapters
  • Output puzzles and coding questions
  • JVM, GC and concurrency internals
₹199₹39950% off
Spring Boot · 100 Q&A

Master Springboot Interview

IoC and DI, REST APIs, Spring Data JPA, transactions and AOP, Security with JWT, microservices, Redis, Kafka and real scenarios.

  • 100 questions in 10 chapters
  • Java and Spring code examples
  • 10 SDE-2 backend scenarios
₹199₹39950% off
Details
Low-level design · Java

Mastering System Design LLD

Turn requirements into clean object models, apply SOLID and design patterns, and practise complete Java LLD problems.

  • Java, OOP, SOLID and UML
  • 23 GoF design patterns
  • 16 detailed LLD case studies
₹299₹59950% off
Details
Complete syllabus

All 100 questions, chapter by chapter

This is the full list. Filter by difficulty, search for a topic such as HashMap or volatile, and open any chapter to see every question in it.

  • 28Beginner
  • 44Intermediate
  • 28Advanced

100 of 100 questions

01Java FundamentalsQ1–Q10 · 10 questionsBeginner

How Java runs, language basics and the foundational questions every round starts with.

  1. Q1What is Java and why is it platform-independent?
  2. Q2JDK vs JRE vs JVM
  3. Q3Compilation and Java bytecode
  4. Q4Features of Java
  5. Q5Primitive vs reference data types
  6. Q6== vs equals()
  7. Q7final vs finally vs finalize()
  8. Q8Static vs instance variables
  9. Q9Is Java pass-by-value?
  10. Q10Method overloading vs overriding
02Object-Oriented ProgrammingQ11–Q20 · 10 questionsBeginner

The four pillars, interfaces, inheritance, polymorphism and immutable object design.

  1. Q11The four pillars of OOP
  2. Q12Encapsulation vs abstraction
  3. Q13Abstract class vs interface
  4. Q14Default and static interface methods
  5. Q15Multiple inheritance in Java
  6. Q16Constructor overloading
  7. Q17Inheritance vs composition
  8. Q18Runtime polymorphism
  9. Q19this vs super
  10. Q20How to write an immutable class
03Strings and Object HandlingQ21–Q28 · 8 questionsBeginner

String internals, the constant pool, equality, copying and the Object class contract.

  1. Q21Why is String immutable?
  2. Q22The String Constant Pool
  3. Q23String vs StringBuilder vs StringBuffer
  4. Q24String literal vs new String()
  5. Q25Shallow copy vs deep copy
  6. Q26Methods of the Object class
  7. Q27The equals() and hashCode() contract
  8. Q28Wrapper classes and autoboxing
04Java Collections FrameworkQ29–Q40 · 12 questionsIntermediate

Collection types, how they are built inside, their complexity and when to pick which.

  1. Q29The Java Collections Framework
  2. Q30List vs Set vs Queue vs Map
  3. Q31ArrayList vs LinkedList
  4. Q32How HashMap works internally
  5. Q33How HashMap handles collisions
  6. Q34HashMap vs Hashtable vs ConcurrentHashMap
  7. Q35HashSet vs LinkedHashSet vs TreeSet
  8. Q36Comparable vs Comparator
  9. Q37Fail-fast vs weakly consistent iterators
  10. Q38PriorityQueue internals
  11. Q39CopyOnWriteArrayList
  12. Q40Choosing the right collection
05Exception Handling and GenericsQ41–Q48 · 8 questionsIntermediate

Robust error handling, resource management, generics and type erasure.

  1. Q41Checked vs unchecked exceptions
  2. Q42How try-catch-finally behaves
  3. Q43Try-with-resources
  4. Q44throw vs throws
  5. Q45Writing custom exceptions
  6. Q46Java generics
  7. Q47Type erasure
  8. Q48Wildcard generics (? extends, ? super)
06Java 8+ and the Stream APIQ49–Q60 · 12 questionsIntermediate

Lambdas, functional interfaces, Streams, Optional and Collectors in practice.

  1. Q49Lambda expressions
  2. Q50Functional interfaces
  3. Q51Predicate, Function, Consumer and Supplier
  4. Q52The Stream API
  5. Q53map() vs flatMap()
  6. Q54Intermediate vs terminal operations
  7. Q55filter(), map() and reduce()
  8. Q56findFirst() vs findAny()
  9. Q57Parallel streams and when to avoid them
  10. Q58Optional
  11. Q59Method references
  12. Q60Collectors.groupingBy() and partitioningBy()
07Multithreading and ConcurrencyQ61–Q72 · 12 questionsAdvanced

Thread safety, locks, visibility, deadlocks and the executor framework.

  1. Q61Process vs thread
  2. Q62The thread lifecycle
  3. Q63Thread vs Runnable vs Callable
  4. Q64start() vs run()
  5. Q65Synchronization and race conditions
  6. Q66synchronized vs ReentrantLock
  7. Q67The volatile keyword
  8. Q68Preventing deadlocks
  9. Q69wait() vs sleep() vs join()
  10. Q70ExecutorService and thread pools
  11. Q71Future vs CompletableFuture
  12. Q72Atomic variables and CAS
08JVM and Memory ManagementQ73–Q82 · 10 questionsAdvanced

JVM architecture, heap and stack, garbage collectors, class loading and the JIT.

  1. Q73JVM architecture
  2. Q74Stack vs heap memory
  3. Q75Metaspace vs PermGen
  4. Q76How garbage collection works
  5. Q77Minor, major and full GC
  6. Q78G1 GC and ZGC
  7. Q79Memory leaks in Java
  8. Q80OutOfMemoryError vs StackOverflowError
  9. Q81The class loading mechanism
  10. Q82The JIT compiler
09Modern Java FeaturesQ83–Q88 · 6 questionsIntermediate

The Java 17 and Java 21 features interviewers now expect you to know.

  1. Q83Java records
  2. Q84Sealed classes and interfaces
  3. Q85Switch expressions and pattern matching
  4. Q86Virtual threads (Java 21)
  5. Q87Text blocks and sequenced collections
  6. Q88Other modern language improvements
10Java Coding and Output QuestionsQ89–Q94 · 6 questionsIntermediate

Trace code like the interviewer does, and write the classic implementations.

  1. Q89String equality output questions
  2. Q90Overloading and overriding output puzzles
  3. Q91Find duplicate elements with Streams
  4. Q92First non-repeating character
  5. Q93LRU cache with LinkedHashMap
  6. Q94A thread-safe counter
11Real-World Java ScenariosQ95–Q98 · 4 questionsAdvanced

Production questions for backend developers: memory, races, latency and caching.

  1. Q95Debugging high memory usage
  2. Q96Investigating a race condition
  3. Q97Diagnosing application latency
  4. Q98Designing a thread-safe cache
12Tricky Java Interview QuestionsQ99–Q100 · 2 questionsAdvanced

Subtle behaviour that shows up as the follow-up that separates good answers from great ones.

  1. Q99Mutable HashMap keys and broken lookups
  2. Q100Why volatile does not make count++ atomic
Free sample

Read five answers from the book

The way every answer is written: a direct reply you can say in the interview, the detail behind it, and the follow-up to expect.

Core JavaBeginner

Is Java pass-by-value or pass-by-reference?

Interview answer

Java is always pass-by-value. For an object, the value that gets copied is the reference, so the method can change the object's state through it, but reassigning the parameter to a new object never changes the caller's variable.

void rename(User u) {
    // same object: caller sees it
    u.setName("Asha");
    // local copy only: caller does not
    u = new User("Ravi");
}

Likely follow-up: What happens if you reassign the object parameter inside the method?

1 / 5
Deep dive

How HashMap.put() works, step by step

The single most asked Java internals question. The book walks through it like this, then covers the collisions, resizing and thread-safety follow-ups.

  1. hashCode()Hash the key

    Calls key.hashCode(), then folds the high 16 bits into the low ones.

  2. indexPick a bucket

    index = (n − 1) & hash. The table size n is always a power of two.

  3. equals()Match the key

    Same hash and equals() is true: replace the value. Otherwise add a node.

  4. treeifyHandle collisions

    A bucket chains nodes; at 8 nodes (table ≥ 64) it becomes a red-black tree.

  5. 0.75Resize

    Past capacity × load factor the table doubles and nodes are split across buckets.

Why it matters: if a key’s fields change after it is stored, its hashCode() changes too and get() looks in the wrong bucket. That is question 99, one of the tricky follow-ups in the last chapter.
Try it now

Five output questions. How many can you get?

Real puzzles of the kind the coding chapter trains you on. Pick an answer to see the explanation.

Java output quiz1/5

What does this print?

StringPool.java
String a = "java";
String b = new String("java");
System.out.println(a == b);
System.out.println(a.equals(b));
Learn by code

Real Java you can run and explain

Implementations from the coding and modern Java chapters, each one a common interview ask.

Find duplicates with the Stream API

A classic coding question, answered with a Set inside a stream. The book explains why this lambda has a side effect and when to prefer groupingBy().

  • Compiles on Java 17 and 21
  • Explained line by line in the ebook
  • Includes the follow-up questions
FindDuplicates.java
import java.util.*;
import java.util.stream.*;

public class FindDuplicates {

    public static void main(String[] args) {
        List<Integer> numbers = List.of(1, 2, 2, 3, 4, 4);

        Set<Integer> seen = new HashSet<>();

        List<Integer> duplicates = numbers.stream()
            .filter(n -> !seen.add(n))   // add() is false if already present
            .distinct()
            .toList();

        System.out.println(duplicates);  // [2, 4]
    }
}
Production thinking

The questions that decide SDE-2 offers

The last chapters move from definitions to debugging. These are the situations you are asked to reason through out loud.

  • Q95 · Memory

    Heap keeps climbing

    Memory rises until OutOfMemoryError. How do you find the leak with GC logs, a heap dump and Eclipse MAT?

    jcmd <pid> GC.heap_dump
  • Q96 · Concurrency

    Counts are wrong under load

    Totals drift only in production. How do you prove a race condition and fix it without killing throughput?

    AtomicLong · LongAdder
  • Q97 · Latency

    p99 latency spikes

    Most requests are fast, some take seconds. Is it GC pauses, lock contention or a saturated thread pool?

    jstack · GC logs
  • Q98 · Design

    A thread-safe cache

    Build an in-memory cache with safe concurrent reads, atomic loading and eviction.

    ConcurrentHashMap.computeIfAbsent
  • Q99 · Tricky

    A key vanishes from HashMap

    You put a key, change one of its fields, and get() now returns null. Why, and how do you prevent it?

    hashCode() of a mutable key
  • Q100 · Tricky

    volatile still loses updates

    Why a visible variable is not an atomic one, and which tool to reach for instead.

    count++ = read + add + write
Revision plan

Seven days to cover all 100 questions

One focused block a day. The question numbers tell you exactly what to read.

  1. Day 01Fundamentals and OOP

    How Java runs, equality, pass-by-value, the four pillars and immutability.

    Ch 01–02 · Q1–Q20
  2. Day 02Strings and exceptions

    String pool, equals and hashCode, exception flow, generics and type erasure.

    Ch 03, 05 · Q21–Q28, Q41–Q48
  3. Day 03Collections

    HashMap internals, ConcurrentHashMap, sets, comparators and iterators.

    Ch 04 · Q29–Q40
  4. Day 04Java 8 and Streams

    Lambdas, functional interfaces, map vs flatMap, Optional and Collectors.

    Ch 06 · Q49–Q60
  5. Day 05Multithreading

    Locks, volatile, deadlocks, executors, CompletableFuture and CAS.

    Ch 07 · Q61–Q72
  6. Day 06JVM and modern Java

    Heap, GC, class loading, JIT, records, sealed classes and virtual threads.

    Ch 08–09 · Q73–Q88
  7. Day 07Mock revision

    Output puzzles, coding questions, production scenarios and tricky follow-ups. Then say every answer out loud.

    Ch 10–12 · Q89–Q100
Who it's for

Made for anyone with a Java interview coming up

  • Students and freshers

    Campus placements and first Java developer interviews, starting from the fundamentals.

  • Java developers

    One to four years in, switching jobs and needing to explain the internals behind daily code.

  • Backend engineers

    Preparing for the Core Java round before Spring Boot, microservices and system design.

  • SDE-1 and SDE-2 candidates

    Concurrency, JVM and production scenarios for the deeper rounds at product companies.

What you get

  • 100 interview questions with detailed answers
  • 12 chapters from fundamentals to internals
  • Likely follow-up for the key questions
  • Java code snippets and output puzzles
  • HashMap, String pool and JVM internals
  • Multithreading and concurrency in depth
  • Java 8 Streams plus Java 17 and 21 features
  • Real-world production scenarios
  • Digital PDF for phone, tablet or laptop
₹199₹39950% off
Questions

Before you buy

Anything else? Write to [email protected]

Is this Java ebook suitable for beginners?

Yes. It starts with Java fundamentals and object-oriented programming, then moves step by step into Collections, Streams, concurrency, JVM internals and advanced topics. Basic Java syntax is enough to begin.

Which Java topics do the 100 interview questions cover?

Core Java, OOP, Strings, the Collections Framework including HashMap internals, exception handling and generics, Java 8 Streams, multithreading and concurrency, JVM memory and garbage collection, modern Java features (records, sealed classes, pattern matching, virtual threads), coding and output questions, real-world scenarios and tricky follow-ups.

Does it cover Java 8, Java 17 and Java 21?

Yes. A full chapter covers Java 8 lambdas, functional interfaces, the Stream API and Optional, and another covers modern Java: records, sealed classes, switch expressions, pattern matching, text blocks, sequenced collections and Java 21 virtual threads.

Does the book include coding and output questions?

Yes. There are code-output puzzles on String equality, overloading and overriding, plus coding questions such as finding duplicates with Streams, the first non-repeating character, an LRU cache with LinkedHashMap and a thread-safe counter.

Is it useful for experienced developers and SDE-2 interviews?

Yes. The later chapters go deep into multithreading, locks, CAS, JVM memory, garbage collectors and production scenarios such as debugging memory leaks, race conditions and latency, which are common in SDE-2 rounds.

Is this a complete Java programming course?

No. It is an interview preparation handbook built around 100 questions, with explanations, examples and follow-ups. It assumes you can already write basic Java.

Is there a Spring Boot interview book too?

Yes. The Spring Boot Interview Handbook has another 100 questions across 10 chapters on Spring Core, REST APIs, JPA, transactions, Spring Security with JWT, microservices, Redis, Kafka and real backend scenarios. Both books are shown in the series section on this page.

How do I get the ebook after paying?

It is a digital PDF ebook, not a physical book. After your payment is confirmed you get access through Target Trek's ebook delivery flow, and you can read it on any phone, tablet or laptop.

Can I get a refund, and how do I contact support?

Digital purchases are non-refundable. For payment or access help, email [email protected].

Walk into the Java round ready for the follow-up.

100 questions, 12 chapters, real code and the internals behind every answer, in one PDF you can read anywhere.

₹199₹39950% off
Resume Lab by Target Trek

Applying everywhere but getting no interview calls?

Your book gets you ready for the interview. A better resume gets you the call. See exactly which lines cost you shortlists, and how to fix each one.

~2 min
AI report
Real people
review it
Pay once
no subscription
Master Java Interviews
₹199₹39950% off