REVIEWED STARTER COLLECTIONBackend Interview Questions
Ye collection Spring Boot aur SQL ke canonical interview chapters ko repeat nahi karta. Focus framework-neutral backend reasoning aur API/application boundaries par hai.
1. What makes a good HTTP API contract?
Short AnswerA good API contract clearly defines resources, routes, HTTP methods, request/response shapes, status codes and error behavior so clients know what to send and what to expect.
Detailed ExplanationThe contract should be predictable and stable enough for clients to integrate safely. Method choice should match the intended operation, validation errors should be consistent, and successful and failed responses should use meaningful HTTP status codes instead of always returning the same status.
GET /courses/42 -> read a course
POST /courses -> create a course
PATCH /courses/42 -> update selected fields
DELETE /courses/42 -> request deletion
Common follow-up: HTTP method semantics are part of the protocol, but the exact business behavior still belongs to the API contract and its documentation.
Review HTTP methods →Review status codes →
2. What does idempotency mean in a backend API?
Short AnswerAn operation is idempotent when repeating the same request has the same intended effect on server state as performing it once.
Detailed ExplanationIdempotency matters when clients retry after timeouts or network failures. Read operations are naturally expected not to create repeated side effects, while write operations may need careful design or an idempotency key when duplicate execution would be harmful.
PUT /users/42/preferences
{
"theme": "dark"
}
Common follow-up: Idempotent does not mean the response bytes must always be identical; it refers to the intended effect of repeating the operation.
Review idempotency →
3. What is the difference between authentication and authorization?
Short AnswerAuthentication establishes who the caller is. Authorization decides what that authenticated caller is allowed to do.
Detailed ExplanationA backend might authenticate a user from a session or token, then evaluate ownership, roles or permissions before allowing access to a resource. Being logged in does not automatically grant permission to every operation.
if (!user) return 401; // not authenticated
if (!canEdit(user, course)) {
return 403; // authenticated, not allowed
}
Common follow-up: Authentication and authorization checks belong on trusted server-side boundaries; hiding a frontend button is not an authorization control.
Review API authentication basics →
4. Why do multi-step backend operations often need a database transaction?
Short AnswerA transaction lets related database changes succeed or fail as one consistency unit, reducing the chance of leaving partial state behind.
Detailed ExplanationSuppose an enrollment operation creates an enrollment row and updates seat availability. If the second step fails after the first succeeds, the data may become inconsistent. A transaction lets the backend commit the whole unit when it succeeds or roll it back when required.
BEGIN;
INSERT INTO enrollments (...);
UPDATE courses
SET seats_left = seats_left - 1
WHERE id = 42;
COMMIT;
Common follow-up: Transactions are not a substitute for validation, authorization or concurrency-aware design. Database-specific transaction details belong in the SQL learning path.
Review database transactions →
5. Why should backend APIs paginate large result sets?
Short AnswerPagination limits how much data is read, processed, transferred and rendered in one request instead of returning an unbounded collection.
Detailed ExplanationLarge responses increase database work, memory usage, latency and network cost. A backend should define sensible limits and deterministic ordering. Offset/page pagination can be simple, while cursor-based approaches can be useful for large or frequently changing datasets.
GET /courses?limit=20&cursor=next-token
{
"items": [...],
"nextCursor": "..."
}
Common follow-up: Pagination design is part of the API contract; clients need to know the ordering, limit rules and how to request the next result set.
Review pagination →