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
- Sr Software EngineerPaypal · San Jose, California, United States of AmericahybridseniorPosted 1 hour ago
- Staff Software EngineerPaypal · San Jose, California, United States of AmericahybridstaffPosted 1 hour ago
- Sr Software EngineerPaypal · Austin, Texas, United States of AmericahybridseniorPosted 1 hour ago
- Software EngineerPaypal · San Jose, California, United States of AmericahybridmidPosted 1 hour ago
- Sr Software EngineerPaypal · San Jose, California, United States of AmericahybridseniorPosted 1 hour ago
- Software EngineerPaypal · Austin, Texas, United States of AmericahybridmidPosted 1 hour ago
- Software Engineer IIIwalmart · Sunnyvale, CAhybridmidPosted 1 hour ago
- (USA) Software Engineer IIIwalmart · (USA) Sam's Home Office AR Bentonville Home OfficeonsitemidPosted 1 hour ago
- Software Engineer, Silicon Design MethodologyOpenAI · San Francisco · RemoteonsitemidQuick applyPosted 2 hours ago
- Staff Software Engineer, Tax AccountsGusto · San Francisco, CAhybridstaffQuick applyPosted 2 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