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.

HardTechnical
41 practiced
Explain how cascading failures and thundering-herd problems propagate in microservices and propose robust defenses to limit blast radius. Discuss admission control, priority queues, randomized retry jitter, circuit-breakers, and token/leader-based approaches to avoid mass retries and overload.
HardTechnical
21 practiced
At the low level in Java, explain the memory-model concerns when designing a lock-free concurrent data structure: visibility, instruction reordering, volatile semantics, atomic compare-and-set, and the ABA problem. Provide concrete techniques to avoid ABA and ensure correctness (for example use versioned references or AtomicStampedReference) and when you would prefer higher-level locks instead.
MediumTechnical
28 practiced
Implement a simple circuit breaker class (pseudocode or Java) that wraps calls to an external HTTP service. Requirements: open after N failures within a rolling window, reject calls while open, transition to half-open after a cooldown period and allow a single probe, and provide a fallback. Describe the metrics you would emit and how you'd tune thresholds.
EasyTechnical
26 practiced
Explain what idempotency means for HTTP APIs and backend operations. Provide at least three concrete examples that demonstrate idempotent versus non-idempotent operations, explain why idempotency is important for safe retries after network failures, and describe a simple server-side technique to make a POST operation idempotent.
HardTechnical
23 practiced
You are asked to define a company-wide error taxonomy and map each error class to an incident response playbook and SLA severity. Describe the taxonomy categories you would introduce, how to operationalize them into alerts, severity levels, runbooks, and on-call escalation, how to document residual risks, and how to train teams to use the taxonomy during on-call rotations.

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.