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
0 practiced
You see intermittent `ConcurrentModificationException` in a Java service processing high-volume events. Propose a sequence of diagnostic steps to reproduce and fix the issue, explain why it happens, and present at least two fixes with their performance implications.
HardTechnical
0 practiced
You discover a reproducible memory leak in a C++ service detected via growing RSS over time and retained pointers found in heap snapshots. Outline concrete fixes and defensive coding patterns (smart pointers, RAII, object pools, diagnostics hooks) you would apply to eliminate leaks and prevent regressions.
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.
MediumTechnical
0 practiced
Implement a `safeDivide(a, b)` function in Python that defensively handles division by zero, non-numeric inputs, and large floats that could produce `inf` or `nan`. Return a structured result like `{ok: bool, value: float|null, error: string|null}` and explain how this design simplifies callers compared to raising exceptions.
MediumTechnical
0 practiced
Describe a layered defense approach against SQL injection in a service that uses both raw queries and an ORM. Include parameterized queries, input validation, least-privilege database users, and runtime monitoring. Provide practical examples of checks you would implement at each layer.

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.