Role preparation
Java Developer interview questions and answers.
JVM services, concurrency, and transactional systems.
Questions
Technical questions to practise out loud
- 01
How does Java HashMap work internally?
HashMap hashes a key into a bucket, resolves collisions with a linked list or tree, and resizes when its load threshold is exceeded; correct equals and hashCode implementations are mandatory.
Read the full breakdown - 02
How does Spring @Transactional work?
@Transactional is normally applied by a Spring proxy that opens, commits, or rolls back a transaction around an intercepted public call; self-invocation bypasses the proxy and rollback defaults matter.
Read the full breakdown - 03
How do you make Java code thread-safe?
Thread safety requires protecting shared invariants through immutability, confinement, atomic classes, locks, or concurrent collections; visibility and compound operations matter, not only individual reads and writes.
Read the full breakdown - 04
How does Java garbage collection affect an application?
Java GC reclaims objects no longer reachable from roots; allocation rate, heap sizing, object lifetime and collector choice affect throughput and pause time, so tune from GC logs and latency goals.
Read the full breakdown - 05
When should you use Java streams?
Streams express transformations over data with lazy intermediate operations and a terminal operation; use them for clear stateless pipelines, not side-effect-heavy logic or automatic parallelism.
Read the full breakdown - 06
How do you secure a Spring application?
Secure Spring applications with explicit authentication, least-privilege authorization at request and method boundaries, CSRF protection where cookies authenticate, safe password hashing, validation, and audited security events.
Read the full breakdown - 07
How does Spring Boot auto-configuration work?
Spring Boot auto-configuration conditionally registers beans based on the classpath, properties, and existing beans; user-defined beans normally override defaults and the conditions report explains decisions.
Read the full breakdown - 08
How do you avoid JPA N+1 queries?
N+1 occurs when one query loads parents and subsequent lazy access issues one query per parent; solve it with a fetch join, entity graph, batch fetching, or a projection chosen for the use case.
Read the full breakdown - 09
How do you diagnose Java performance problems?
Diagnose Java performance from evidence: correlate service metrics and traces, inspect GC and thread states, capture JFR or async-profiler data, fix the measured bottleneck, and rerun the same workload.
Read the full breakdown - 10
How do you design exception handling in Java?
Use exceptions for exceptional failures, preserve causes, expose domain-specific errors at boundaries, avoid catch-all swallowing, and translate once into an API or retry decision where enough context exists.
Read the full breakdown