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
0 practiced
You maintain a parser that must handle large input files safely. Describe defensive measures to avoid memory exhaustion or stack overflows: streaming parsing, input size limits, tail recursion removal, and graceful error responses. Include how to test these limits in CI.
MediumTechnical
0 practiced
Create a plan for regression tests that verify fallback behavior when a cache tier fails. Include test orchestration steps, how to inject cache failures in test and staging, and what assertions ensure both correctness and acceptable performance degradation.
EasyTechnical
0 practiced
Give a short explanation of ReDoS (Regular Expression Denial of Service). What defensive coding techniques would you use to prevent ReDoS in user-supplied patterns or validation regexes in a web application? Include performance and usability trade-offs.
MediumTechnical
0 practiced
Implement an exponential backoff with full jitter retry helper in Python: signature `retry(func, max_attempts=5, base_delay=0.1, max_delay=10.0)` where `func` is a callable that may raise exceptions. Ensure delays are randomized, that the function is safe for concurrent use, and document when this pattern is appropriate.
HardTechnical
0 practiced
You are paged for a production issue: multiple services experience increasing 5xx errors after a deploy. Provide a prioritized incident response plan: immediate mitigation steps to reduce customer impact, how to gather diagnostics safely, rollback vs patch decision criteria, and post-incident actions to prevent recurrence.

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.