Core language
- `equals` and `hashCode`. The contract between them, and what breaks when you override one and not the other - objects vanishing inside a `HashSet` is the answer they want.
- `==` versus `.equals` for objects, and the Integer cache that makes `==` appear to work for small values.
- Checked versus unchecked exceptions, and a defensible opinion on when checked exceptions are worth it.
- `final`, `finally`, `finalize` - a tired question that still gets asked.
- Interfaces versus abstract classes, including default methods and what they changed.
- String immutability and why the string pool exists.
Collections
- `ArrayList` versus `LinkedList` - and the honest answer that `ArrayList` wins in practice far more often than the big-O table suggests, because of cache locality.
- How `HashMap` works, including collision handling and what happens on resize. Expect a follow-up on why a poor `hashCode` degrades it.
- `HashMap` versus `ConcurrentHashMap`, and why `Hashtable` is not the answer.
- When would you use a `TreeMap`? Ordering, and the cost that ordering carries.
- Fail-fast iterators and `ConcurrentModificationException` - what triggers it and how to avoid it.
Concurrency
- What does `volatile` actually guarantee - visibility, not atomicity. This distinction is the question.
- `synchronized` versus a `ReentrantLock`, and what the latter gives you that the former does not.
- What is a race condition, and how would you detect one you suspect but cannot reproduce?
- Why is `ExecutorService` preferable to creating threads directly?
- What is a deadlock, and what are the conditions required for one?
- What does the `happens-before` relationship mean in the Java memory model?
Modern Java and the JVM
If the role is on a recent LTS, expect streams (lazy evaluation, when a stream is slower than a loop), `Optional` used properly rather than as a null wrapper, and records. On the JVM side: heap versus stack, roughly what generational garbage collection does, and how you would approach an `OutOfMemoryError` in production - heap dump first, not a bigger heap. Spring-specific questions are their own topic and are usually flagged in the job description.
How deep it goes by level
- Junior: the fundamentals above, explained clearly. Nobody expects production scars yet, and honesty about what you have not done reads better than bluffing.
- Mid-level: the same ground, plus a service you have shipped. Expect follow-ups asking why you made a particular choice rather than whether you know the syntax.
- Senior: JVM tuning you have actually done, and a migration between major versions. At this level the language questions get shorter and the judgement questions get longer.
Whatever the level, the reliable way to prepare is to say your answers out loud rather than reading them. Most of what candidates lose in a Java interview is lost in the gap between knowing something and explaining it under observation - the method is in how to use AI for interview prep.
Where CoPilot Interview fits
Disclosure: we build an interview assistant, so treat this as a disclosed pitch. CoPilot Interview is a native Windows and macOS app that puts suggested answers on your own screen in about two seconds, across coding, system design and behavioral rounds, with a permanent free tier that needs no credit card.
Frequently asked questions
What are the most common Java interview questions?
The `equals` and `hashCode` contract, how `HashMap` works internally, `ArrayList` versus `LinkedList`, what `volatile` guarantees, and the difference between checked and unchecked exceptions. Concurrency questions are where candidates most often struggle.
What happens if you override equals but not hashCode?
Objects that are equal can produce different hash codes, so hash-based collections break - you put an object into a `HashSet` or `HashMap` and cannot find it again, because the lookup goes to a different bucket. That concrete failure is the answer interviewers want.
What does volatile guarantee in Java?
Visibility, not atomicity. Writes to a volatile field are visible to other threads immediately, but a compound operation like increment is still not thread-safe. Confusing the two is one of the most common mistakes in Java concurrency questions.
Is ArrayList or LinkedList better?
`ArrayList` in almost all real cases. The big-O table favours `LinkedList` for insertions, but contiguous memory and cache locality mean `ArrayList` usually wins in practice, and saying that shows practical experience rather than textbook recall.
Walk into the round with a second pair of eyes
CoPilot Interview is a native Windows and macOS app that puts suggested answers on your own screen in about two seconds, across coding, system design and behavioral rounds. The free tier is permanent: 15 minutes a day, no credit card.
Try it free