Recognizing Try-Except Usage
In Python, which structure is used to catch and handle exceptions that may arise during code execution?
- try-except
- do-catch
- handle-exception
- catch-try
- try-handle
Understanding Status Codes
When a backend API encounters a client error, which HTTP status code is commonly returned?
- 400
- 200
- 500
- 304
- 100
Custom Exception Class Name
What is the correct way to name a custom exception class in Python, following common conventions?
- InvalidInputError
- invalidinputerror
- invalid_input
- Invalidinputerror
- InputErrorInvalid
Handling Multiple Exceptions
How can you handle multiple exceptions in a single try block in Python?
- except (TypeError, ValueError):
- except TypeError or ValueError:
- catch [TypeError, ValueError]:
- handle TypeError, ValueError:
- except TypeError, ValueError:
Dealing with Uncaught Exceptions
What typically happens when an exception is not caught or handled in a backend application?
- The application crashes or terminates
- The exception is silently ignored
- The process will freeze indefinitely
- A warning message is shown to user only
- Code execution continues as normal
Logging Errors Properly
Why is it important to log exceptions in production backend systems?
- To aid debugging and monitor failures
- To show stack traces to end users
- To prevent the code from running
- To speed up API responses
- To clear application cache
Finally Clause Purpose
What is the purpose of the 'finally' block in a try-except-finally statement in Python?
- It always runs regardless of whether an exception occurred
- It only runs if an exception was caught
- It is used to raise new exceptions
- It skips all code in the try block
- It ends the program
Exception Propagation in Functions
If a function does not handle an exception, what will happen to the exception?
- It propagates up to the caller
- It disappears automatically
- It is logged silently
- It is converted to a warning
- It is retried three times
Avoiding Sensitive Information Leaks
Why should you avoid returning detailed exception or stack trace data to API clients?
- It may expose sensitive internal logic or data
- It helps the client debug faster
- It increases server speed
- It is required by HTTP specification
- It allows better caching
Error Handling in Asynchronous Code
When using async/await in backend code (e.g., Python's asyncio), what should you use to handle exceptions?
- try-except blocks
- finally-except blocks
- catch await blocks
- expect async blocks
- error-await blocks