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
- Software Engineer Intern - Summer 2027Paypal · San Jose, California, United States of AmericahybridentryPosted 4 mins ago
- Sr. Software Engineer – Cloud Infrastructure and DevopsPaypal · Chicago, Illinois, United States of AmericahybridseniorPosted 4 mins ago
- Senior Software EngineerAbbott · United States > Madison : 1 Exact LaneonsiteseniorPosted 5 mins ago
- Lead Software Engineervisa · US - Bellevue, WAonsiteleadPosted 6 mins ago
- Software DeveloperParsons · US - VA, RestononsitemidPosted 9 mins ago
- Software Engineer - ServiceNow Platform EngineerPNC · PA - Pittsburgh (15219)onsitemidPosted 15 mins ago
- Software Engineering Manager-AI/MLKLA · Ann Arbor, MIonsitemidPosted 24 mins ago
- Software Engineer - Computer VisionVerkada · San Mateo, CA United StatesonsitemidQuick applyPosted 25 mins ago
- Senior Software Engineer - CamerasVerkada · San Mateo, CA United StatesonsiteseniorQuick applyPosted 26 mins ago
- Software DeveloperVera Whole Health · Fort Myers, FLonsitemidPosted 31 mins 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