Java rewards people who understand what the JVM is doing. These questions check the fundamentals — equality, collections, concurrency — that separate a real backend engineer from a framework operator.
Hiring a Java developer is easy. Telling a real one from a convincing résumé is the hard part — and it’s most of what we do. These are grouped by level, because the same question that stretches a junior is a warm-up for a senior.
Junior Java interview questions
0–2 years
Equality, exceptions and collections.
What’s the difference between == and .equals()?
== compares references (identity) for objects, while .equals() compares value; if you override equals() you must override hashCode() too. They know Strings must be compared with .equals().
Compares Strings with == and is surprised it sometimes “works.”
Checked vs unchecked exceptions — when to use each?
Checked exceptions must be declared or handled and model recoverable conditions; unchecked (runtime) exceptions signal programming errors. They don’t catch-and-swallow broadly.
Wraps everything in catch (Exception e) and does nothing with it.
When would you use a List, a Set, and a Map?
List keeps order and allows duplicates, Set enforces uniqueness, Map stores key-value pairs; they can pick ArrayList vs LinkedList and explain why. Right structure for the access pattern.
Doesn’t know a Set dedups or when a Map is the obvious fit.
Mid-level Java interview questions
2–5 years
HashMap internals and concurrency primitives.
How does a HashMap work, and why do hashCode and equals matter?
Keys are bucketed by hashCode and resolved within a bucket by equals; a poor hashCode degrades to near-linear lookups, and mutable keys corrupt the map. They override both together.
Uses mutable objects as keys or overrides only one of the two methods.
What do synchronized, volatile and the concurrent collections each give you?
synchronized provides mutual exclusion, volatile guarantees visibility (not atomicity of compound operations), and atomics offer lock-free updates and ConcurrentHashMap offers high-concurrency access via fine-grained locking. They reason about happens-before.
Thinks volatile makes count++ thread-safe.
Where do Streams and Optional help, and where do they hurt?
Streams express declarative pipelines cleanly and Optional models absence at return sites; overusing Optional in fields/parameters or putting side effects in a stream is a smell. Right tool, right place.
Calls Optional.get() without checking, or mutates state inside a stream.
Senior Java interview questions
5+ years
JVM, concurrency at scale and Spring pitfalls.
What do you know about JVM memory and GC tuning?
Heap generations, modern collectors (G1, ZGC), sizing heaps to the workload, and hunting leaks from retained references or thread-locals — backed by profiling. They don’t set -Xmx by superstition.
No GC awareness; tunes flags by guesswork.
How do you design for concurrency at scale?
Bounded thread pools via ExecutorService, immutability and minimal shared mutable state, CompletableFuture for composition, and awareness of backpressure and deadlock. Structured, not ad-hoc threads.
Spawns unbounded threads and shares mutable state without synchronisation.
What Spring pitfalls have caught you out?
The @Transactional self-invocation trap (proxy-based, so internal calls bypass it), transaction-boundary placement, and proper layering. They understand Spring is proxies, not magic.
Puts @Transactional on a self-invoked or private method and expects it to apply.
Browse the full series on the interview questions hub, or see how we assess engineers in our interview process.