Java Backend Developer Interview Questions & Answers
40 questions for Java Backend Developer interviews — 7 easy, 28 medium, 5 hard.
About the Java Backend Developer role
A Java backend developer designs and builds REST APIs and business logic with Spring Boot, JPA and relational databases. The role involves writing clean, tested code, tuning queries, handling transactions and integrating with other services. It is in strong demand at fintechs, ecommerce firms and banks, which expect solid Java, Spring and SQL skills plus an understanding of performance and reliability.
Bind typed configuration properties with validation in Spring Boot.
Show answer
How does Spring Boot auto-configuration work?
Show answer
An API listing 100 orders fires 101 SQL queries. How do you fix it?
Show answer
A query is fast in development but takes 8 seconds in production. How do you investigate?
Show answer
What is the difference between map() and flatMap()?
Show answer
What is the N+1 select problem in Hibernate and how do you fix it?
Show answer
Write a unit test for a service class using JUnit 5 and Mockito.
Show answer
What is the difference between JPA, Hibernate and Spring Data JPA?
Show answer
You need to process a 5 GB file using streams without running out of memory. How?
Show answer
What is Spring Boot and how is it different from the Spring Framework?
Show answer
Explain the entity lifecycle states in JPA.
Show answer
How do you explain OOP concepts to a junior developer who is new to Java?
Show answer
A batch job inserting 1 lakh rows through JPA takes 30 minutes. How do you speed it up?
Show answer
How do you handle a situation where you made a wrong technical decision?
Show answer
Tell me about a time you made a codebase more readable.
Show answer
Write a stream to partition numbers into even and odd lists.
Show answer
Your Spring Boot service takes 40 seconds to start in Kubernetes and pods get killed. How do you fix it?
Show answer
Using streams, find the employee with the highest salary in each department.
Show answer
Why is PreparedStatement preferred over Statement?
Show answer
Write a minimal Dockerfile for a Spring Boot application.
Show answer
Users get LazyInitializationException when the API returns an entity. What is happening?
Show answer
What is the difference between lazy and eager loading?
Show answer
Write a JDBC batch insert for a list of products.
Show answer
You must expose configuration that differs between dev, QA and production. How do you manage it?
Show answer
Legacy code uses anonymous classes and loops everywhere. How would you modernise it safely?
Show answer
toMap() throws Duplicate key exception in production. How do you fix it?
Show answer
A stream pipeline that updates a shared ArrayList in forEach gives random results with parallel(). Why?
Show answer
What is the difference between reduce() and collect()?
Show answer
Explain bean scopes in Spring.
Show answer
A @Transactional method is not rolling back after an exception. What could be wrong?
Show answer
Write a Kafka producer and consumer in Spring Boot.
Show answer
Map a one-to-many relation between Order and OrderItem in JPA.
Show answer
What is Spring Boot Actuator used for?
Show answer
What does effectively final mean for lambdas?
Show answer
Tell me about a time you found and fixed a difficult production bug in a Java application.
Show answer
Write a Spring Data JPA repository method that fetches orders with items to avoid N+1.
Show answer
Write a sealed interface with records and a switch that computes area.
Show answer
Flatten a list of lists of integers and compute the sum of squares of the even numbers.
Show answer
Clients report duplicate orders when they retry after a timeout. How do you prevent it?
Show answer
Frequently asked questions
What does a Java Backend Developer do?
A Java backend developer designs and builds REST APIs and business logic with Spring Boot, JPA and relational databases. The role involves writing clean, tested code, tuning queries, handling transactions and integrating with other services. It is in strong demand at fintechs, ecommerce firms and banks, which expect solid Java, Spring and SQL skills plus an understanding of performance and reliability.
Which skills are tested in a Java Backend Developer interview?
Expect questions on Spring Boot, REST APIs, JPA and Hibernate, SQL tuning, JUnit and Mockito. Most rounds also ask you to explain a project and solve one practical problem live.
How do I prepare for a Java Backend Developer interview?
Revise Spring Boot and Microservices, JDBC, Hibernate and JPA, Java 8+ Features and Streams first using the topic sheets, practise the questions on this page aloud, then do one full mock interview to practise timing.