Java interview questions
Practice explaining your reasoning, checking assumptions, and supporting your answers with real examples.
Prepare to show your thinking
These java questions are practice prompts, not a prediction of a particular company’s interview. A strong answer explains your reasoning and adapts to the interviewer’s constraints. Start by clarifying the question and state assumptions before proposing a solution.
Use examples from work or projects you actually completed. If you have not encountered a situation, say so and explain how you would approach it. Do not turn a hypothetical answer into a fabricated personal story.
How would you choose between an interface and an abstract class?
Explain the contract, shared behavior, inheritance constraints, and how future implementations may differ.
Practice aloud for two minutes, then ask yourself which assumptions you left unstated. A follow-up to prepare for: what would make you choose a different approach?
What can go wrong when mutable data is shared between threads?
Discuss race conditions, visibility, synchronization, and a design that reduces shared state.
Use one concrete example and explain how you would verify that your answer works. A follow-up to prepare for: what failure case have you not yet considered?
How do you handle errors at an API boundary?
Separate validation, expected domain failures, and unexpected exceptions. Explain logging and safe client messages.
Distinguish the ideal design from what is reasonable under time and resource constraints. A follow-up to prepare for: how would you explain this choice to a colleague?
Review your practice answer
Record or write a short answer, then check four things: did you answer the actual question, make your assumptions visible, support the key claim, and explain a tradeoff? Revise the structure rather than memorizing a script.
Prepare one question of your own about how the team approaches this work. An interview can help you understand expectations as well as demonstrate your skills.
Questions worth asking
Should I memorize sample answers?+
No. Practice a structure and use real evidence. Memorized scripts make it harder to respond when the interviewer changes the constraints.
What if I do not know the answer?+
Say what you know, identify the gap, and explain how you would investigate. Ask a clarifying question and avoid pretending certainty.