InterviewStack.io LogoInterviewStack.io

Java Backend Development Questions

Practical ability to build backend services using the Java ecosystem and to reason about relational data access and query performance. Candidates should demonstrate idiomatic Java coding, service design, dependency injection, testing strategies, error handling, and production observability. They should be able to write and optimize SQL queries, reason about join strategies and indexing, interpret query execution plans, and explain denormalization trade offs. Additional topics include concurrency and thread safety, transaction management and isolation levels, profiling and memory management, debugging slow queries and performance bottlenecks, and practices for delivering maintainable, production quality backend code.

HardTechnical
56 practiced
You need to add a new NOT NULL column with a computed default to a table containing 2 billion rows without blocking writes or causing long locks. Design a zero-downtime migration plan detailing schema rollout steps, backfill strategy (chunked updates, background workers), how to avoid table rewrites or large transactions, how to change the application to be compatible across versions, and how to validate correctness.
MediumTechnical
52 practiced
Given the following simplified schema:
users(id BIGINT PRIMARY KEY, name TEXT, email TEXT)orders(id BIGINT PRIMARY KEY, user_id BIGINT REFERENCES users(id), status VARCHAR(20), created_at TIMESTAMP, total_amount NUMERIC)order_items(order_id BIGINT REFERENCES orders(id), product_id BIGINT, quantity INT)
Consider this query used by an API to fetch recent orders with total_amount > 100 for a given user, including item count:
SELECT o.id, o.created_at, o.total_amount, COUNT(oi.*) AS item_countFROM orders oJOIN order_items oi ON oi.order_id = o.idWHERE o.user_id = ? AND o.total_amount > 100GROUP BY o.id, o.created_at, o.total_amountORDER BY o.created_at DESCLIMIT 50;
Explain what indexes you would add to improve performance for this query, why those indexes help, and any trade-offs (write amplification, storage). Also discuss possible query rewrites or schema changes (for example denormalizing item_count) to further optimize.
EasyTechnical
50 practiced
Explain dependency injection in Java backend applications and compare constructor injection, setter injection, and field injection in Spring. Describe advantages and disadvantages of each approach, testability implications, and common pitfalls (for example circular dependencies). Provide a short Java (Spring Boot) example showing constructor injection for a Service that depends on a UserRepository.
EasyTechnical
66 practiced
In Java 8+, describe and (optionally) write a short JDBC code example that executes a simple SELECT and demonstrates correct resource management with try-with-resources. Show creating the Connection, PreparedStatement, executing the query, iterating the ResultSet, and handling SQLExceptions. Explain why try-with-resources prevents resource leaks compared to manual finally blocks.
HardTechnical
56 practiced
You observe frequent long GC pauses (hundreds of milliseconds) on a Java 11 service when load increases. Outline diagnostic steps to determine whether GC is the root cause and propose tuning and configuration changes to reduce pauses: heap sizing, G1 tuning parameters, garbage collector choices (G1 vs ZGC vs Shenandoah), GC logging and analysis, and how to validate improvements in staging and production.

Unlock Full Question Bank

Get access to hundreds of Java Backend Development interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.