Top 10 JVM Interview Questions Every Fresher Should Know
Top 10 JVM Interview Questions Every Fresher Should Know Work through these 10 questions out loud. Open any question for the full model answer, the trap to avoid, and the follow-up a panel usually asks.
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....
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...
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...
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....
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