Java Coding Interview Checklist
Java interviews expose ceremony and strength at once: verbose types can slow you down, but explicit structure helps you communicate. A checklist keeps you from losing points to import misses, collection misuse, or silent nulls while you focus on the algorithm.
Use this Java coding interview checklist before, during, and at the end of a round.
Before you type logic
- [ ] Confirm Java version assumptions if relevant (streams, records, var)
- [ ] Read the method signature; do not change it unless allowed
- [ ] Restate inputs/outputs and constraints
- [ ] Note nullability: can arrays/lists/strings be null? empty?
- [ ] Pick the collection that matches access patterns
Talk track:
“I’ll clarify null and empty cases, then implement with a HashMap for O(1) lookups.”
Write constraints in a one-line comment so you do not “optimize” into breakage later.
Imports and scaffolding
Common needs:
java.util.*— List, ArrayList, HashMap, HashSet, Deque, ArrayDeque, PriorityQueuejava.util.Collections— when sorting helpers help- Prefer
ArrayDequeover legacyStack
If the pad auto-imports, still name types clearly. If it does not, write imports early so you do not thrash later.
Skeleton:
public int solve(...) {
// plan
// edge: null / empty
return 0;
}
For multi-file pads, keep helpers close and public signatures untouched.
Collections chooser (memorize)
| Need | Type |
|---|---|
| Dynamic array | ArrayList |
| Fast membership | HashSet |
| Key → value | HashMap |
| FIFO BFS | ArrayDeque |
| Min/max priority | PriorityQueue |
| Sorted unique | TreeSet |
Say why you picked it in one line. Wrong structure costs more than verbose syntax. For max-heap patterns, remember comparator reversal on PriorityQueue.
Null and edge checklist mid-solve
- [ ] Null input handling matches prompt
- [ ] Empty list/array returns the specified value
- [ ] Single-element behavior verified
- [ ] Integer overflow considered for sums/products
- [ ] Comparator consistency for priority queues and sorts
- [ ] Duplicate keys / duplicate values considered
For strings: null vs ""; for arrays: null vs length 0—ask if unclear. For boxed types, beware unexpected nulls in lists.
Implementation habits that save time
- Prefer enhanced for-loops when indexes are unnecessary
- Use
map.getOrDefault(k, 0)ormergefor counts - Initialize lists with capacity only if it stays readable
- Extract a private helper when nesting exceeds comfort
- Avoid premature micro-optimizations of boxing
- Prefer
equalsfor content, not==, for objects
Streams: fine if you are fluent under stress; otherwise loops are safer in interviews. A half-remembered collector costs more time than a for-loop.
Complexity talk track
After the first working version:
“Time O(n), space O(n) for the map. Bottleneck is the single pass.”
If you sort:
“Sorting dominates at O(n log n); extra space depends on the sort.”
If you use a heap for top-k:
“Heap of size k gives O(n log k).”
Debugging checklist when tests fail
- Reproduce with the smallest failing example
- Check off-by-one on loops (
<vs<=) - Check map keys (mutability / wrong equals)
- Check whether you mutated an input you should not
- Re-read the return type (int vs long, list vs array)
- Confirm you handled the prompt’s duplicate policy
Freeze recovery
- [ ] Narrate the stuck point
- [ ] Write brute force with clear nested loops if needed
- [ ] Mark complexity honestly
- [ ] Replace hot spot with a better structure
- [ ] Keep compiling after each small change
Visible progress beats redesigning the entire class hierarchy in your head.
End-of-round pre-submit checklist
- [ ] Compiles (or would compile): types and returns match
- [ ] Edges: null, empty, single, duplicates
- [ ] No leftover debug prints
- [ ] Helpers named clearly
- [ ] Complexity stated
- [ ] Example dry-run completed aloud
Practice plan
| Session | Focus |
|---|---|
| 1 | Type HashMap counting and ArrayDeque BFS cold |
| 2 | Medium problem with explicit null/empty guards |
| 3 | PriorityQueue pattern (top-k) |
| 4 | Full timed pad + end checklist |
Soft practice note
If you want a Chrome side panel for calm narration and freeze recovery while you rehearse Java pads, Luna Interview supports that practice loop. Use it to build composure—never as a substitute for knowing Java or for anything that violates interview rules.
One-page day-of card
Clarify → edges → collection choice → brute/optimal → dry-run → complexity → clean prints. Run the checklist every time until it is muscle memory.
Rehearse with an AI interview copilot, then browse commonly reported interview questions.