Binary SemaphoreBinary Semaphore/learn
mentorshiptopicsroadmapsnotebooks
sign in
CC++JavaPythonJavaScriptTypeScriptGoDSAOperating SystemsNetworksDatabasesSystem DesignTheory and CompilersMaths for CSFrontendBackend and APIsSecurityCloud and DevOpsTestingAIGit and the ShellDebuggingInterviews and Viva
Java
  • memory-and-gc
  • concurrency-traps
  • collections-in-anger
  • equals-and-hashcode
  • interview-questions
  • viva-defence

© 2026 Binary Semaphore

discord

Java

What gets asked

The Java questions that come up in nearly every round.

The Java interview is more predictable than almost any other part of the process. The same eight or nine things come up, and they come up because each one has a wrong answer that sounds right.

What follows is not a list to memorise. It is what each question is actually checking, which is the part that decides how you do.

The ones that always come up

"Difference between an interface and an abstract class." Since default methods arrived the mechanical differences shrank, so the honest answer is about intent: an interface is a capability something has, an abstract class is a partial implementation things share. If you only recite "a class can implement many interfaces", you have answered the 2010 version.

"What is the difference between == and .equals()?" Reference identity against value equality. The follow-up is always about String, and the answer involves the string pool: literals are interned and shared, new String("a") is not, so == can be true for two literals and false for two objects holding the same characters.

"Is Java pass by value or pass by reference?" Always pass by value. The subtlety is that when the value is a reference, you get a copy of the reference, so you can mutate the object it points at but reassigning the parameter does nothing outside the method. People who say "pass by reference for objects" are describing the right behaviour with the wrong words, and the interviewer is listening for exactly that.

"Why must you override hashCode when you override equals?" Because a hash-based collection finds the bucket first and compares second. Get this one right and it usually ends the topic.

"What does static actually mean?" It belongs to the class, not an instance. The real follow-up is why a static method cannot use this, and whether static state is safe across threads, which it is not.

"What is final?" Three separate meanings: a field that cannot be reassigned, a method that cannot be overridden, a class that cannot be extended. Note the first one does not make the object immutable, and say so before they ask.

More on this is coming, and asking moves it up the list.

Want this written up?

Sign in and tell us. We write the ones people actually ask for, and asking takes one click.

Sign in to ask

Or sit with someone on it instead of waiting for us to write it.

What we have

Nothing yet, and no canonical source worth pointing at.

Book an hour on this

"Checked or unchecked exceptions?" Checked means the compiler forces you to handle or declare it. The interesting answer is your opinion on when checked exceptions earn their cost, because most modern code prefers unchecked.

"How does a HashMap work?" Buckets from the hash, equals inside the bucket, resize when the load factor is passed, and since Java 8 a bucket that gets too long becomes a tree rather than a list.

"What is volatile?" Visibility and ordering, not atomicity. If you can add that volatile int count still loses increments, you have shown you understand it rather than remembered it.

What is really being tested

Almost none of this is knowledge retrieval. They already assume you can look things up.

They are checking whether you can be precise under mild pressure. Whether "I am not certain, here is how I would check" comes out instead of a confident wrong answer. Whether you notice the follow-up is a different question from the first one.

The two that separate people

"Tell me about a bug you found that was hard." This is the real question in the whole interview. They want to hear a method: what you observed, what you suspected, how you narrowed it, what it turned out to be. A story with a hypothesis in it beats a story with a hero in it.

"Why did you do it that way?", asked about your own code. There is no preparation for this other than having actually made the decision. If an agent wrote it and you did not review it, this is exactly where that shows.

How to prepare, briefly

Write the answers out loud rather than reading them. The failure mode is almost never not knowing. It is knowing and not being able to say it in order.