Interview prep
Java Interview Questions
Java interviews lean on collections, concurrency and JVM behaviour. Enterprise employers also probe Spring Boot patterns.
Questions and answers
01What is the difference between HashMap and ConcurrentHashMap?
HashMap is unsynchronised and can corrupt or infinite-loop under concurrent writes. ConcurrentHashMap uses per-bin locking and CAS so reads are lock-free and writes contend only on the affected bin.
02Explain the Java memory model in terms of heap and stack.
Each thread has its own stack holding frames and primitives; objects live on the shared heap. Escaping references, not allocation size, are what force objects to survive across frames.
03What does the volatile keyword guarantee?
Visibility and ordering, not atomicity. A volatile read sees the latest write from any thread, but compound operations such as i++ still need synchronisation or an atomic class.
04Checked vs unchecked exceptions — when do you use each?
Checked exceptions model recoverable, caller-actionable conditions; unchecked exceptions model programming errors. Modern codebases lean unchecked and wrap at boundaries rather than propagating checked types everywhere.
05How does garbage collection work on the JVM?
Generational collectors split the heap into young and old regions, collecting the young generation frequently and cheaply. G1 and ZGC add region-based, mostly-concurrent collection to keep pause times bounded.
How to answer these well
Interviewers are not grading recall — they are checking whether you've hit the failure mode the question describes. Anchor every answer to something you actually shipped or debugged with Java.
Say the trade-off out loud. "I'd use X here, but it costs Y under Z conditions" scores higher than a clean textbook definition every time.
Roles asking for Java
- Staff/ Principal Software Engineer (L6/L7): AI Platform Model ServingNetflix · Remote, United States · RemoteremoteleadPosted 1 hour ago
- Staff Software Engineer, Tech FoundationsAirbnb · United StatesonsitestaffQuick applyPosted 1 hour ago
- Software Engineer, GenAI PlatformRoblox · San Mateo, CA, United StatesonsitemidQuick applyPosted 1 hour ago
- Staff Software Engineer - Backend NetworkingDragos · United StatesonsitestaffQuick applyPosted 2 hours ago
- Principal Software Engineer - Roblox DatabaseRoblox · San Mateo, CA, United StatesonsiteleadQuick applyPosted 2 hours ago
- Sr. Staff Software Engineer, AI Native Web PlatformDatabricks · Mountain View, CaliforniaonsitestaffQuick applyPosted 2 hours ago
- Principal Software Engineer, GPU ComputeRoblox · San Mateo, CA, United StatesonsiteleadQuick applyPosted 2 hours ago
- Senior Software Engineer, AI Teammates PlatformAsana · San FranciscoremoteseniorQuick applyPosted 3 hours ago
- Software Engineer, ComputeVercel · Hybrid - San FranciscoremotemidQuick applyPosted 3 hours ago
- Principal Embedded Software EngineerRocket Lab · Tucson, AZonsiteleadQuick applyPosted 4 hours ago
Related prep
- Software Engineer jobs
- Software Engineer career guide
- Backend Engineer jobs
- Backend Engineer career guide
- Python interview questions
- JavaScript interview questions
- React interview questions
- AWS interview questions
- Azure interview questions
- Kubernetes interview questions
- Docker interview questions
- Terraform interview questions