InterviewStack.io LogoInterviewStack.io

Code Quality, Error Handling, and Defensive Programming Questions

Writing robust, high-quality code that fails safely. Covers defensive programming, input validation, error handling and fault tolerance, logging for diagnosability, and general engineering-quality standards. Includes anticipating failure modes and making code resilient to bad inputs and unexpected states.

EasyTechnical
29 practiced

A boundary check validates that a value (an index, an offset, a size) falls within the range the code actually handles correctly, and it routinely catches real production bugs before they cause damage. Pick three DIFFERENT kinds of boundary bugs you've seen or can construct realistically, and for each: describe the bug it would cause if unchecked, the specific defensive check you'd add, and a unit test that would catch a regression if the check were later removed.

MediumTechnical
23 practiced

How would you verify, before an incident happens, that your circuit breakers and timeouts actually work as intended, rather than trusting they do because the code was reviewed?

MediumTechnical
29 practiced

A developer adds a null-check to fix a crash bug. What regression risk does this kind of small defensive fix introduce, and how would you test to make sure the fix doesn't quietly swallow a case that should have been surfaced as an error?

HardTechnical
28 practiced

You need to verify that a payment endpoint is safe to retry, meaning a client that times out and retries doesn't create a duplicate charge. How would you test this, and what would the endpoint need to implement to make it testable?

MediumTechnical
28 practiced

What is fuzz testing, and how would you use it to find defensive-programming gaps, like unhandled exceptions or crashes, in a service that parses untrusted file uploads?

Unlock Full Question Bank

Get access to all 11 Code Quality, Error Handling, and Defensive Programming interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.