InterviewStack.io LogoInterviewStack.io

Error Handling and Code Quality Questions

Focuses on writing production quality code and scripts that are defensive, maintainable, and fail gracefully. Covers anticipating and handling failures such as exceptions, missing files, network errors, and process exit codes; using language specific constructs for error control for example try except blocks in Python or set minus e patterns in shell scripts; validating inputs; producing clear error messages and logs; and avoiding common pitfalls that lead to silent failures. Also includes code quality best practices such as readable naming and code structure, using standard libraries instead of reinventing functionality, writing testable code and unit tests, and designing for maintainability and observability.

EasyTechnical
0 practiced
Explain log levels (DEBUG, INFO, WARNING, ERROR, CRITICAL) and give concrete examples of what belongs at each level in a backend web service. Describe how an engineer should decide which level to use for:
- A transient network timeout to an internal cache- A user providing malformed input- An assertion failure due to a bug in business logic
Discuss how log levels affect storage and alerting strategies in production.
HardTechnical
0 practiced
In modern C++, implement a small RAII wrapper FileHandle that opens a file descriptor in its constructor and ensures close() is called in the destructor. Requirements:
- Support move semantics (move constructor and move assignment), but disable copying.- Ensure behavior is safe if an exception is thrown while another stack is unwinding.- Discuss noexcept, resource release guarantees, and how this pattern prevents leaks compared to manual open/close.
Provide sample code and explanation.
HardTechnical
0 practiced
You observe a memory leak in a Java service that seems to correlate with exception-heavy paths. Describe how exceptions can cause leaks (e.g., retaining references, caches populated on failure), how to diagnose the leak using heap dumps and flame graphs, and concrete fixes to prevent accidental retention on error paths.
HardSystem Design
0 practiced
Design an error classification and metric system for a web platform: define categories (validation, client-misuse, infrastructure, transient-network, bug), required fields in each error event, and how to map them to alert priorities and SLO impact. Provide examples for three error events and show how they would appear in dashboards.
EasyTechnical
0 practiced
In Java, write a method String getNormalizedEmail(User user, String fallback) that safely returns the lowercase email of a possibly-null nested object (user.getProfile().getContact().getEmail()). Requirements:
- Do not throw NullPointerException; return the fallback if any element is null or empty.- Prefer standard Java idioms (Optional or defensive checks) and explain the trade-offs.
Provide the implementation and justify when to favor Optional vs. defensive null checks in a codebase.

Unlock Full Question Bank

Get access to hundreds of Error Handling and Code Quality interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.