Core Java (Must Know)

These questions test if you truly understand the language.

Key Questions

  • What is the difference between HashMap and ConcurrentHashMap?

  • Explain equals() vs hashCode() contract.

  • Difference between final, finally, finalize.

  • What happens when you override equals but not hashCode?

  • Difference between ArrayList and LinkedList.

  • What is immutability? Why is String immutable?

  • What are Java Records and when should you use them?

  • Difference between Comparable vs Comparator.

  • What is Optional and when should it NOT be used?

Classic Trick Question

Why is HashMap not thread safe?

Expected answer:

  • race conditions during resize

  • lost updates

  • infinite loops in older JDK versions

2. Java Memory Model & JVM

Senior engineers are expected to know JVM behavior.

Key Questions

  • What are the different memory regions in JVM?

Answer:

  • Heap

  • Stack

  • Metaspace

  • Code Cache

  • Native Memory

Important JVM Question

How does Garbage Collection work?

Explain:

  • Young Generation

  • Old Generation

  • Minor GC

  • Major GC

Advanced Question

What is Stop-the-World?

Answer:
All application threads pause during GC.

JVM Performance Question

How do you troubleshoot memory leak in Java?

Answer:

Tools:

  • jmap

  • jvisualvm

  • heap dump

  • MAT (Memory Analyzer Tool)

3. Concurrency (VERY Important for Senior Role)

Key Questions

  • Difference between Runnable vs Callable

  • What is Future vs CompletableFuture

  • What is volatile keyword

  • What is synchronized vs Lock

  • What is deadlock

Important Question

What is ThreadLocal?

Answer:

ThreadLocal provides thread-specific variables.

Example:

ThreadLocal<SimpleDateFormat> formatter = ThreadLocal.withInitial(
    () -> new SimpleDateFormat("yyyy-MM-dd")
);

Used heavily in:

  • logging

  • transaction context

  • security context

Classic Interview Question

Difference between wait() vs sleep()

sleep()

wait()

Thread class

Object class

does NOT release lock

releases lock

time based

signal based

4. Serialization & APIs

Important Question

How do microservices typically serialize data?

Answer:

Most common:

  • JSON (Jackson)

Alternatives:

  • Protocol Buffers

  • Avro

  • Thrift

Follow-up Question

Why is JSON slower?

Answer:

  • text format

  • larger payload

  • parsing overhead

Binary formats like Protobuf are faster.

5. Spring Boot / Microservices

These questions appear in almost every interview.

Key Questions

  • What happens when a Spring Boot application starts?

  • What is Dependency Injection

  • Difference between @Component, @Service, @Repository

  • What is Spring Bean lifecycle

Important Question

What is the difference between @RestController vs @Controller

Annotation

Purpose

@Controller

MVC view

@RestController

REST API

Microservices Questions

  • What is service discovery

  • What is API Gateway

  • What is circuit breaker

  • What is idempotency

6. Security Questions

Especially important in banking interviews.

Common Questions

  • What is CORS

  • What is CSRF

  • What is OAuth2

  • What is JWT

Important Question

Where should SSL terminate?

Answer:

Common architectures:

1️⃣ At Load Balancer (ALB)
2️⃣ At API Gateway
3️⃣ Inside container

Each has different security tradeoffs.

7. System Design (Senior Level)

These questions determine if you are architect level.

Example Questions

  • Design URL shortener

  • Design rate limiting service

  • Design distributed cache

  • Design log aggregation system

Microservices Design Question

How do you prevent cascading failure?

Answer:

  • Circuit Breaker

  • Bulkhead

  • Retry

  • Timeout

8. Docker & Cloud (Very common now)

Questions

  • What is multi-stage Docker build

  • What is Docker layer caching

  • What is sidecar container

  • Difference between container vs VM

9. Database Questions

Key Questions

  • Difference between optimistic vs pessimistic locking

  • What is ACID

  • What is transaction isolation level

  • What is N+1 query problem

10. Debugging / Real World Questions

These separate Senior vs Mid-level developers.

Examples

  • API latency suddenly increased → how do you debug?

  • Thread pool exhaustion → what do you check?

  • CPU spikes in production → how do you investigate?

  • GC running every few seconds → what does it mean?

Expected tools:

  • thread dump

  • heap dump

  • profiling

⭐ The 5 Questions That Almost ALWAYS Appear

If you remember only these, you will still perform well:

1️⃣ HashMap vs ConcurrentHashMap
2️⃣ Java Memory Model
3️⃣ CompletableFuture vs Future
4️⃣ Spring Bean lifecycle
5️⃣ How to debug memory leak in production

I am creating a Guide for all of these , please subscribe if you are interested and consider supporting me.

Keep Reading