← Back to blog

Java interview questions and answers

Java interview questions and answers — cover from Greenroom, the AI mock interviewer

Java is still one of the most-interviewed languages on the planet — services companies, product companies, and Android roles all test it heavily. The good news: Java interview questions are predictable and finite. Master core OOP, collections, exceptions, multithreading, and a bit of JVM internals, and you'll handle most rounds. Here are the Java interview questions that actually get asked, with answers.

Core Java & OOP

Collections framework

Java interview topics — OOP, collections, exceptions, concurrency, JVM
Java rounds reward knowing the 'why' behind collections and the JVM, not just syntax.

Exceptions & multithreading

JVM & memory

The core truth: Java interviews reward knowing the why — why String is immutable, how HashMap resolves collisions, when ArrayList beats LinkedList. Memorized definitions crack under one follow-up; understanding survives it.

How to prepare

Java rounds are conversational — interviewers ask "why" and "what happens if". Practise explaining concepts out loud, not just reading them. Greenroom runs spoken technical interviews that follow up on your answers and give feedback on clarity. Pair it with our OOPs and SQL guides.

Frequently asked questions

What are the most common Java interview questions?

Common Java questions cover OOP pillars, == vs .equals() and the equals/hashCode contract, abstract class vs interface, String vs StringBuilder vs StringBuffer, the collections framework (ArrayList vs LinkedList, how HashMap works internally), checked vs unchecked exceptions, multithreading and synchronization, and JVM/memory topics like heap vs stack and garbage collection.

How does a HashMap work internally in Java?

A HashMap stores entries in an array of buckets. It computes the key's hashCode, maps it to a bucket index, and stores the key-value pair there. When multiple keys hash to the same bucket (a collision), entries are chained in a linked list, which converts to a balanced tree once a bucket grows large enough, improving worst-case lookup performance.

Why is String immutable in Java?

String is immutable for security, thread-safety, and performance reasons: immutable strings can be safely shared and cached, used as reliable HashMap keys, and pooled in the String pool to save memory. Because the value never changes after creation, multiple references can share one object without risk of one reference altering another's data.

How should I prepare for a Java interview?

Master core OOP, the collections framework, exceptions, multithreading and basic JVM internals, focusing on the 'why' behind each concept since interviewers ask follow-up questions. Then practise explaining these out loud, ideally with a voice-based mock interview that follows up on your answers, because Java rounds are conversational rather than write-and-submit.

Java rounds reward understanding you can explain out loud. Greenroom runs spoken technical interviews that follow up on your answers and give feedback. Free to start.