InterviewStack.io LogoInterviewStack.io

Error Handling and Defensive Programming Questions

Covers designing and implementing defensive, fault tolerant code and system behaviors to prevent and mitigate production failures. Topics include input validation and sanitization, null and missing data handling, overflow and boundary protections, exception handling and propagation patterns, clear error reporting and structured logging for observability, graceful degradation and fallback strategies, retry and backoff policies and idempotency for safe retries. Also address concurrency and synchronization concerns, resource and memory management to avoid exhaustion, security related input checks, and how to document and escalate residual risks. Candidates should discuss pragmatic trade offs between robustness and complexity, show concrete defensive checks and assertions, and describe test strategies for error paths including unit tests and integration tests and how monitoring and operational responses tie into robustness.

MediumTechnical
24 practiced
Implement a thread-safe token-bucket rate limiter in Java with methods boolean tryAcquire() and void refill(). The limiter should support configurable burst capacity and sustained replenishment rate. Describe concurrency primitives used and the complexity of operations.
EasyTechnical
28 practiced
Explain idempotency in distributed systems. Provide three techniques to achieve idempotent operations (idempotency keys with stored responses, unique constraints/de-duplication at the database level, and write-once semantics) and discuss the trade-offs (storage cost, expiration, concurrency).
MediumTechnical
21 practiced
As an SRE guiding a team, design a layered test strategy covering error paths: unit tests that simulate failures, integration tests with test doubles, contract tests for downstream behavior, and failure-injection/chaos tests for real dependencies. Give concrete examples and describe automation in CI (gating vs non-gating).
MediumTechnical
31 practiced
Design and provide pseudocode for an idempotent POST endpoint for a payments service that accepts an 'Idempotency-Key' header. Requirements: ensure at-most-once effect or consistent responses on retries, handle concurrent requests with the same key, expire keys after 24 hours, and store enough response metadata to replay identical responses. Describe storage and locking choices.
EasyTechnical
25 practiced
Explain the difference between transient and permanent errors in networked services (examples: DNS timeout vs 401 unauthorized). For each type, describe appropriate retry behavior: when to retry, retry limits, and fallback strategies. Explain how idempotency and side effects affect retry decisions.

Unlock Full Question Bank

Get access to hundreds of Error Handling and Defensive Programming interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.