Top 25 JVM Interview Questions for Experienced Developers
Top 25 JVM Interview Questions for Experienced Developers Work through these 15 questions out loud. Open any question for the full model answer, the trap to avoid, and the follow-up a panel usually asks.
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...
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...
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...
Why did JDK 27 make G1 the default GC everywhere, and when would you still pick Serial or ZGC?
First I check the collector in the new CI log. If it flipped Serial → G1, that is JEP 523 — not a 27 regression. I keep G1 in prod with equal heap and a pause goal. I only...
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....
JDK 27 is not LTS. What do you inherit on upgrade without writing new application code?
I would not pin 27 as LTS — 25 is still the pin. On a 27 canary I inherit G1 in CI that used to pick Serial, compact headers, and hybrid TLS if the JDK terminates TLS. I...
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....
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:...
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...
What did generational ZGC change in JDK 21, and when would you pick it over G1?
For a large-heap, latency-sensitive API I trial generational ZGC in staging: p99 pause, allocation rate, and RSS. I keep G1 if throughput or CPU is the SLO. I never flip...
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...
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...
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...
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...
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...
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