Java is still one of the most-interviewed languages on the planet — services companies, product companies, and Android roles all test it heavily. The good news: Java interview questions are predictable and finite. Master core OOP, collections, exceptions, multithreading, and a bit of JVM internals, and you'll handle most rounds. Here are the Java interview questions that actually get asked, with answers.
Core Java & OOP
- Explain the four OOP pillars in Java (our OOPs guide).
- Difference between
==and.equals(); the relationship betweenequals()andhashCode(). - Difference between an abstract class and an interface (and what changed with default methods).
- What is the difference between
String,StringBuilder, andStringBuffer? - What is immutability, and why is
Stringimmutable?
Collections framework
- ArrayList vs LinkedList — when to use each.
- HashMap vs HashTable vs ConcurrentHashMap; how a HashMap works internally (buckets, hashing, collisions).
- HashSet vs TreeSet vs LinkedHashSet.
- fail-fast vs fail-safe iterators.
Exceptions & multithreading
- Checked vs unchecked exceptions;
final,finally,finalize. - How do you create a thread? Runnable vs Thread; the thread lifecycle.
- What is synchronization, a deadlock, and how do you avoid one?
- What does the
volatilekeyword do?
JVM & memory
- Explain the JVM, JRE, and JDK.
- Heap vs stack memory; what garbage collection does.
- What is the difference between pass-by-value and pass-by-reference in Java?
How to prepare
Java rounds are conversational — interviewers ask "why" and "what happens if". Practise explaining concepts out loud, not just reading them. Greenroom runs spoken technical interviews that follow up on your answers and give feedback on clarity. Pair it with our OOPs and SQL guides.
Frequently asked questions
What are the most common Java interview questions?
Common Java questions cover OOP pillars, == vs .equals() and the equals/hashCode contract, abstract class vs interface, String vs StringBuilder vs StringBuffer, the collections framework (ArrayList vs LinkedList, how HashMap works internally), checked vs unchecked exceptions, multithreading and synchronization, and JVM/memory topics like heap vs stack and garbage collection.
How does a HashMap work internally in Java?
A HashMap stores entries in an array of buckets. It computes the key's hashCode, maps it to a bucket index, and stores the key-value pair there. When multiple keys hash to the same bucket (a collision), entries are chained in a linked list, which converts to a balanced tree once a bucket grows large enough, improving worst-case lookup performance.
Why is String immutable in Java?
String is immutable for security, thread-safety, and performance reasons: immutable strings can be safely shared and cached, used as reliable HashMap keys, and pooled in the String pool to save memory. Because the value never changes after creation, multiple references can share one object without risk of one reference altering another's data.
How should I prepare for a Java interview?
Master core OOP, the collections framework, exceptions, multithreading and basic JVM internals, focusing on the 'why' behind each concept since interviewers ask follow-up questions. Then practise explaining these out loud, ideally with a voice-based mock interview that follows up on your answers, because Java rounds are conversational rather than write-and-submit.