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
31 practiced
Describe a layered, defense-in-depth approach to input validation and authorization in a multi-tenant backend: include checks at the API gateway, service-level validation, tenant ownership verification, and database-level constraints. Explain what threat each layer defends against and what to log or redact at each boundary.
MediumTechnical
24 practiced
Your recommendations microservice provides optional personalized suggestions but is increasing latency under peak load and affecting core flows. Propose a graceful degradation plan (immediate mitigations and longer-term changes) that protects core request latency while minimizing user impact, including feature flags, caching, prioritization, and fallback responses.
EasyTechnical
46 practiced
A user profile service returns records with optional fields (middleName, phoneNumber, preferredLocale). Describe three practical strategies for handling null or missing data across the API, service layer, and database layer. For each strategy discuss pros/cons, impact on consumers, storage choices, and how to minimize runtime null-related exceptions.
HardTechnical
30 practiced
A production backend process crashes with OOM after running for 24–48 hours. Outline a step-by-step incident diagnosis and mitigation plan: include immediate low-risk hotfixes to reduce customer impact, instrumentation you would add to collect heap dumps and allocation metrics safely, profiling approaches you would use in production, and long-term fixes and validation plans.
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.

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.