← All interview questions

Skill Zuno · skillzunos.com · Fullstack

Java interview questions

Prepare for Java interviews on Skill Zuno. This practice book covers Java interview questions across New, Easy, Medium, Hard, and Diff levels so you can work through real interview-style problems on skillzunos.com.

Open Java on Skill Zuno

Also see the Java tutorial.

Java is a statically typed, object-oriented language that compiles to bytecode for the Java Virtual Machine. It is widely used for enterprise back ends, Android and big-data systems. Java interviews focus on OOP, the Collections framework, equals and hashCode, generics, exceptions, concurrency and JVM memory.

Sample Java interview questions

How does HashMap work internally?

HashMap stores entries in an array of buckets. The key's hashCode() picks a bucket and equals() finds the key inside it. Collisions form a linked list that turns into a balanced tree once a bucket grows past eight entries, and the table doubles when it passes its load factor (0.75).

Why must you override hashCode() when you override equals()?

Equal objects must have equal hash codes. Otherwise two equal keys can land in different buckets, so HashMap and HashSet fail to find entries or store duplicates.

What is the difference between an abstract class and an interface?

An abstract class can hold state, constructors and any mix of abstract and concrete methods, and a class extends only one. An interface has no instance state; it can have default and static methods, and a class can implement many.

What does volatile guarantee?

A volatile field is always read from and written to main memory, so every thread sees the latest value and reads and writes are not reordered around it. It does not make compound actions such as count++ atomic.

What is the difference between checked and unchecked exceptions?

Checked exceptions such as IOException must be caught or declared with throws. Unchecked exceptions extend RuntimeException, such as NullPointerException, and usually signal programming errors that need no declaration.

What you can practice

  • Java interview questions for beginners and experienced developers
  • Level-based practice: New, Easy, Medium, Hard, and Diff
  • Fullstack topics alongside Java on skillzunos.com

More Fullstack interview questions

All interview questions