/Java Interview Questions: Core, Collections & Concurrency
Programming 11 min read

Java Interview Questions: Core, Collections & Concurrency

Core Java, collections, concurrency, and Spring questions with crisp answers and prep tips.

Introduction

This guide is for Java developers from freshers to mid-level. Java interviews reward deep understanding of core concepts, the collections framework, and concurrency.

Read this if you want a structured refresher before a Java technical round.

Overview

  • Core Java: OOP, memory model, exceptions, generics.
  • Collections: List, Set, Map, Queue internals and Big-O.
  • Concurrency: threads, locks, executors, and the java.util.concurrent package.
  • Ecosystem: Spring, Hibernate, and JVM tuning for backend roles.

Preparation Tips

  • Know HashMap internals (buckets, hashing, resize) — it's asked constantly.
  • Understand fail-fast vs fail-safe iterators and ConcurrentHashMap.
  • Be fluent in try-with-resources and checked vs unchecked exceptions.
  • For backend roles, revise Spring DI, lifecycle, and transaction basics.
  • Practice 2–3 small coding problems (strings, collections) out loud.

Top Interview Questions

1. How does HashMap work internally?

Array of buckets; hash → index; collisions handled by linked list or tree (Java 8+). Resize doubles capacity when load factor exceeded.

2. Difference between == and .equals()?

===== compares references; .equals() compares logical equality (overridable). Always override hashCode when overriding equals.

3. What is the difference between ArrayList and LinkedList?

ArrayList: O(1) random access, O(n) insert/delete mid. LinkedList: O(1) insert/delete at ends, O(n) access. Choose by access pattern.

4. Explain ConcurrentHashMap vs synchronized HashMap.

ConcurrentHashMap allows concurrent reads and segment-level (Java 7) or bin-level (Java 8+) locking; better throughput than full synchronization.

5. What is volatile in Java?

Ensures visibility of changes across threads (no caching in CPU registers) but doesn't guarantee atomicity for compound actions — use Atomic* or locks.

Common Mistakes

  • Overriding equals() without overriding hashCode().
  • Confusing checked vs unchecked exceptions.
  • Misusing synchronized when ConcurrentHashMap fits better.
  • Not knowing time complexity of common collections.

Expert Tips

  • Draw the HashMap bucket structure while explaining — it shows depth.
  • Connect concurrency answers to real race conditions you've debugged.
  • For Spring, know bean scopes and where transactions propagate.
  • Always mention complexity when answering collections questions.

Frequently Asked Questions

Is Java still in demand in 2026?

Yes — enterprise backends, Android, and big data ecosystems keep Java demand strong.

Do I need Spring for Java interviews?

For backend roles, basic Spring (DI, lifecycle, transactions) is commonly expected.

How deep should I go on JVM internals?

Know classloading, memory areas, and GC basics; deep tuning is for senior roles.

What's the best way to prepare Java concurrency?

Read java.util.concurrent, write small thread demos, and practice race-condition questions.

Related Articles

Ready to test yourself?

Practice Java interview questions with an AI interviewer and get rubric-based feedback.

Start a Mock Interview

Practice this with AI feedback

PrepyX listens to your answers and gives you instant, detailed feedback — structure, clarity, confidence, and more.

Try PrepyX Free