Skip to content
QSWEQB

Java & Spring interview questions

Language and framework depth for JVM roles, covering the internals that separate framework users from engineers who understand what runs underneath.

15 published across 10 topics.

Java fundamentals75 short answers on one page, for revising rather than studying.

Core Java

2 questions

Object semantics, equals and hashCode contracts, generics, exceptions, and immutability.

mediumConceptCoding

If you override equals but not hashCode, what breaks and when?

Equal objects must produce equal hash codes. Break that and a HashMap sends lookups to a bucket the entry was never placed in, so the map holds a value you can no longer retrieve and a set silently admits duplicates. The same failure appears later if a key is mutated after insertion.

4 minentry, mid, senior

Collections Framework

2 questions

Implementation internals, resizing behaviour, ordering guarantees, and choosing the right collection.

mediumConcept

How does HashMap work internally, and what happens when it resizes?

HashMap stores entries in an array of buckets indexed by a hash of the key; collisions chain into a linked list that converts to a red-black tree past a threshold, and exceeding the load factor triggers a resize that reallocates and redistributes every entry.

3 minentry, mid, senior

Concurrency & Multithreading

2 questions

The memory model, executors, locks, atomics, virtual threads, and diagnosing races and deadlocks.

mediumConceptDesign

What problem do virtual threads actually solve, and when do they not help?

Virtual threads make blocking cheap by unmounting from their carrier OS thread whenever they block, so thread-per-request scales to hundreds of thousands of concurrent tasks. Finalised in JDK 21, they do nothing for CPU-bound work, and pooling them defeats their purpose.

5 minmid, senior, staff
hardConceptCoding

What does volatile guarantee, and what does it not?

It guarantees visibility and ordering: a volatile write happens-before every later read of that field, so everything the writer did beforehand becomes visible to the reader. It guarantees nothing about atomicity, so an increment is still a race and a volatile reference says nothing about the object it points to.

5 minmid, senior, staff

JVM Internals & Tuning

2 questions

Class loading, memory regions, garbage collectors, and reading a heap dump or GC log.

hardScenarioConcept

A service dies with OutOfMemoryError in production. Walk me through diagnosing it.

Read the message text first, because it names which region ran out. Then use the GC log to see whether the live set after each full collection is trending upward, which means a leak, or flat and close to the ceiling, which means the heap is simply too small. A heap dump tells you what is retaining the memory.

5 minmid, senior, staff

Streams & Functional Java

1 question

Lazy evaluation, collectors, parallel streams, and the readability and performance traps.

Modern Java Features

1 question

Records, sealed types, pattern matching, and the language changes that reshape idiomatic code.

mediumConceptDesign

How do records, sealed types and pattern matching change the way you model a domain?

Together they let you write closed data hierarchies the compiler can check. A record declares that a type is its components, a sealed interface enumerates the permitted variants, and an exhaustive switch over record patterns turns adding a variant into a compile error at every place that handles them.

5 minmid, senior, staff

Spring Core

1 question

Dependency injection, bean lifecycle, scopes, proxies, and why an AOP annotation silently does nothing.

Spring Boot

1 question

Auto-configuration mechanics, configuration precedence, actuator, and production-readiness concerns.

Spring Data & JPA

2 questions

Entity lifecycle, lazy loading and N+1, transaction propagation, and generated-SQL debugging.

Testing on the JVM

1 question

Unit versus integration boundaries, mocking strategy, Testcontainers, and suite design.