Advanced JVM Interview Questions for Senior Engineers

Advanced JVM Interview Questions for Senior Engineers Work through these 12 questions out loud. Open any question for the full model answer, the trap to avoid, and the follow-up a panel usually asks.

  1. Explain JIT compilation tiers (C1, C2) and warmup.

    JMH @Warmup iterations required. Production: readiness probe after warmup traffic or use Kubernetes minReadySeconds. Serverless: GraalVM native or tiered warmup requests....

    Full answer

  2. Your application memory usage keeps increasing over time. What do you suspect?

    Suspect memory leak if heap used grows after GC without traffic drop. Capture heap dump on OOM (`-XX:+HeapDumpOnOutOfMemoryError`), compare dominator tree. Common in Spring:...

    Full answer

  3. What are hidden classes in JDK 15, and which runtime frameworks rely on them?

    I do not write hidden classes in business code. I know JDK 15+ lambdas and several proxy libraries use them so generated bytecode unloads cleanly. If a heap dump shows...

    Full answer

  4. Explain garbage collection basics in the JVM.

    New objects allocate in Eden; minor GC copies survivors to survivor spaces, then old gen. When old gen fills, major/full GC runs — longer pauses. Tune -Xmx, choose G1 for...

    Full answer

  5. How do CompletableFuture and virtual threads compare for concurrency?

    Use virtual threads when business logic is naturally blocking — call DB, call HTTP, return. Use CompletableFuture when composing multiple independent async results with...

    Full answer

  6. Compare G1, ZGC, and Shenandoah garbage collectors.

    Default G1 fine for most Spring Boot services — tune -XX:MaxGCPauseMillis=200. Payment API p99 SLA <10ms GC pause: try -XX:+UseZGC on Java 21 large heap. Benchmark with JMH and...

    Full answer

  7. What is Metaspace and how do class loading issues cause memory leaks?

    Production set MaxMetaspaceSize 256m with monitoring. Investigate Metaspace OOM: heap dump + classloader histogram. Avoid generating unlimited dynamic proxies. OSGi/script...

    Full answer

  8. JVM container awareness and memory settings for Kubernetes?

    Container limit 1Gi: JAVA_TOOL_OPTIONS=-XX:MaxRAMPercentage=75.0 -XX:InitialRAMPercentage=50.0. Monitor container memory vs heap used in Actuator metrics. Leave headroom for...

    Full answer

  9. Autoscaling enabled but error rate increases. Why?

    New pods accept traffic before JVM/Caffeine warm. HPA adds API pods but Postgres max connections fixed. ```yaml readinessProbe: initialDelaySeconds: 30 ``` Scale connection...

    Full answer

  10. When do useMemo and useCallback actually help — and when do they make things worse?

    I memoize a filtered 10k-row list or a value passed into a memoized DataGrid. I do not wrap every onClick. Profiler + why-did-you-render first. In React 19 I let the compiler...

    Full answer

  11. Which JVM and library changes in JDK 15 show up in production ops, not just language trivia?

    If we touched 15 on the way to 17/21, I check three ops items: collector is no longer experimental so flags change, ZGC may uncommit so RSS graphs look different, and any...

    Full answer

  12. IdentityHashMap vs HashMap — when would you use IdentityHashMap?

    Use when identity matters not value — tracking object visitation in deep graph walk. Business keys (userId, email) belong in HashMap with proper equals/hashCode....

    Full answer

JVM Interview Questions and Answers · Top 50 JVM Interview Questions and Answers (2026 Edition) · Top 40 JVM Interview Questions | Must-Prepare before interview. · JVM Interview Questions Every Fresher Must Know

All interview question lists · Interview guides · Home · Support the platform