Java Interview Questions to Ask Before You Hire

Java interviews fail when they test trivia the IDE remembers for everyone. These questions instead probe the JVM, concurrency judgment, and Spring depth that decide how a candidate performs in the large, long-lived systems where Java actually lives β€” with notes on what strong answers cover.

4.9/5from US hiring teams
βœ“$0 until you hireβœ“Top 2% of US talentβœ“48h average time to hireβœ“No recruitment fees

13 Java interview questions β€” with what to listen for

  1. 1

    Explain how the JVM manages memory β€” heap generations, garbage collection, and what you tune when.

    What a strong answer covers

    Young and old generations, minor versus full collections, and modern collectors (G1 default, ZGC for low pause). Tuning stories should start from evidence β€” GC logs, allocation profiling β€” not cargo-culted flags. Knowing when the answer is 'fix the allocation, not the collector' is the senior tell.

  2. 2

    equals and hashCode: what is the contract, and what breaks when it is violated?

    What a strong answer covers

    Equal objects must share hash codes; violations silently break HashMap and HashSet lookups β€” elements vanish or duplicate. Records and IDE generation as the modern practice, plus the mutable-key-in-a-map trap as the war story worth telling.

  3. 3

    Walk me through the collections you actually reach for and why β€” including when a LinkedList is ever the right answer.

    What a strong answer covers

    ArrayList and HashMap as workhorses with growth and load-factor awareness, ConcurrentHashMap for shared maps, EnumMap/EnumSet niceties. The honest answer on LinkedList is 'almost never' given cache behavior β€” that honesty is the point of the phrasing.

  4. 4

    Explain volatile, synchronized, and the java.util.concurrent tools. How do you decide which level to work at?

    What a strong answer covers

    volatile for visibility without atomicity, synchronized/locks for mutual exclusion, and a strong preference for higher-level tools: concurrent collections, ExecutorService, CompletableFuture, atomics. Happens-before reasoning at a working level separates real concurrency experience from keyword recall.

  5. 5

    What are virtual threads, and how do they change how you write concurrent Java services?

    What a strong answer covers

    Lightweight JVM-scheduled threads making thread-per-request viable at high concurrency without async gymnastics; pinning pitfalls with synchronized blocks around blocking calls; where reactive stacks still make sense. This question also dates a candidate's currency with modern Java releases.

  6. 6

    A production JVM service has p99 latency spikes every few minutes. How do you investigate?

    What a strong answer covers

    GC pauses as the first suspect via GC logs, then thread dumps for lock contention or pool exhaustion, JFR or async-profiler for flame graphs, connection-pool and downstream-dependency checks. A tool-named, ordered method is the pass; guessing is the fail.

  7. 7

    How does Spring dependency injection work, and what have you seen go wrong with bean scopes or circular dependencies?

    What a strong answer covers

    Constructor injection as the default, singleton scope assumptions, circular-dependency resolution and why its appearance signals design smell, and proxy-based behavior underlying much of Spring. Real anecdotes about @Transactional or lazy-init surprises are worth extra credit.

  8. 8

    Explain how @Transactional actually works and the classic ways it silently does nothing.

    What a strong answer covers

    Proxy-based interception: self-invocation bypasses the proxy, private methods are not intercepted, checked exceptions do not roll back by default, and propagation settings change semantics. This is among the highest-yield Spring questions because the failures are silent in production.

  9. 9

    How do you keep a Spring Boot service's startup, memory footprint, and dependency sprawl under control?

    What a strong answer covers

    Deliberate starter selection, excluding autoconfiguration not in use, profiling startup, container-aware JVM sizing, and native-image or CDS awareness as options. Treating the framework as a set of choices rather than an inevitability is the mindset being screened.

  10. 10

    Streams and lambdas: where do they improve code, and where have you seen them abused?

    What a strong answer covers

    Clear wins in transformation pipelines and readability; abuse in deeply nested streams, side effects inside map, parallel streams applied without measurement or with shared mutable state. Preferring a plain loop when clearer signals maturity rather than weakness.

  11. 11

    What changed in Java that you actually use since Java 8 β€” records, sealed types, pattern matching, text blocks?

    What a strong answer covers

    Concrete usage: records for data carriers, sealed interfaces with exhaustive switch for domain modeling, pattern matching reducing casting ceremony. A candidate still writing Java 8 idioms on a modern JDK is leaving safety and clarity on the table β€” this question surfaces that quickly.

  12. 12

    How do you test Java services β€” unit, integration, and the database boundary?

    What a strong answer covers

    JUnit 5 with Mockito used judiciously, Spring slice tests versus full-context costs, Testcontainers for real databases and brokers over in-memory approximations, and contract tests where services integrate. Fast-suite discipline β€” keeping the full build tolerable β€” is the operational marker.

  13. 13

    You inherit a fifteen-year-old Java monolith on an old JDK. What are your first moves?

    What a strong answer covers

    Characterization tests around critical paths, JDK upgrade path with dependency audit, observability before refactoring, and incremental extraction only where the business case exists. Respect for working legacy code, plus a plan to make it changeable, is exactly what enterprise Java work demands.

Skip the interviews entirely β€” get matched with pre-vetted Java developers in 48 hours, $0 until you hire.

Need a custom question set?

Our free interview question generator builds a tailored list for any role, seniority, and focus area.

Try the interview question generator β†’

Frequently asked questions

How current do these questions stay across Java versions?

The JVM, collections, and Spring questions are durable. The virtual-threads and modern-features questions are deliberate currency checks β€” refresh them against the latest LTS every year or two, and treat a candidate's answer as evidence of whether they track the platform at all.

Kotlin developers are applying for our Java role. Do these questions still work?

Mostly yes β€” JVM, concurrency, Spring, and testing questions transfer directly. Swap the language-feature questions for their Kotlin equivalents and confirm reading fluency in Java if your codebase is Java-first.

What is the best practical exercise for a Java hire?

A code review of a small Spring service with planted defects: a self-invoked @Transactional method, a mutable HashMap key, an unbounded thread pool. It tests the exact silent-failure knowledge these questions target, in under an hour.

Ready to hire?

Vetted talent ready for US teams. No recruitment fees. Zero risk.

πŸ‡ΊπŸ‡Έ Trusted by companies across the United States