Java & Spring Boot interview questions

OOP pillars, equals/hashCode, collections, exceptions, JVM memory, concurrency and Spring Boot essentials.

Readiness: 0 of 15 nailed

How to use this page: 1. Read a question2. Type your answer3. Check with AI4. Open the model answer5. Timed drill when you’re 70% ready

Core Java

FoundationConcept

Explain the four pillars of OOP with simple examples.

JuniorIt’s broken: why?

You put new User("ali") in a HashSet, then set.contains(new User("ali")) returns false. Why?

JuniorConcept

Checked vs unchecked exceptions?

FoundationConcept

Why are Strings immutable in Java? String vs StringBuilder?

FoundationPredict the output

What does this print?

String a = new String("hi");
String b = new String("hi");
System.out.println((a == b) + " " + a.equals(b));
FoundationConcept

What do final, finally and finalize mean?

Collections

JuniorConcept

ArrayList vs LinkedList, HashMap vs TreeMap?

JuniorWrite it by hand

Use Java streams to get the names of active users, sorted.

JVM

Mid-levelConcept

Stack vs heap memory, and what causes OutOfMemoryError?

Spring Boot

JuniorConcept

What is a Spring Bean and how does dependency injection work in Spring Boot?

Mid-levelIt’s broken: why?

@Transactional doesn’t roll back. What are the common causes?

Mid-levelIt’s broken: why?

A Spring Boot endpoint triggers hundreds of SQL queries. Why?

JuniorConcept

How do you manage different configs for dev, staging and production in Spring Boot?

Concurrency

SeniorConcept

How would you make a counter thread-safe? What are virtual threads?

Modern Java

JuniorConcept

What are records and Optional?

Also prepare