Top 3 Winners:
Vishal Khatal, Rishabh Mourya and Ganesh Kale
Congratulations!!
Quiz Questions and answers are below:
1. What is the purpose of the ‘finally’ block?
- To catch exceptions
- To execute code after a try block, regardless of whether an exception was thrown
- To skip code execution
- To throw an exception
Correct Answer: Option 2
2. What is exception chaining?
- Linking multiple exceptions together to form a hierarchy
- Catching exceptions in multiple try blocks
- Wrapping one exception inside another to preserve the original exception
- Using multiple catch blocks for one try block
Correct Answer: Option 3
3. Chain of Responsibility pattern is a pattern where one object takes all responsibilities?
- True
- False
Correct Answer: Option 2
4. Which of the following statements is not a recommended practice?
- Catching only exceptions you can handle
- Logging detailed error information
- Using exceptions for control flow
- Rethrowing exceptions to higher levels when necessary
Correct Answer: Option 3
5. In a multithreaded application, what should you do if you need to handle exceptions in a thread-safe manner?
- Handle exceptions outside the threads
- Handle exceptions inside each thread and use synchronization for shared resources
- Ignore exceptions to improve performance
- Use the sleep method to manage exceptions
Correct Answer: Option 2
6. What happens if an exception is not caught in a thread?
- The application continues normally
- The thread stops execution and the exception is ignored
- The exception is propagated to the main thread automatically
- The application may terminate if the exception is unhandled
Correct Answer: Option 4
7. What should you do when creating a custom exception class?
- Ignore the base exception class
- Only implement the default constructor
- Implement constructors that support message and inner exception parameters
- Override the ToString method only
Correct Answer: Option 3
8. Which of the following statements best describes the purpose of Retry Pattern?
- To retry a failed operation a specified number of times before giving up
- To ignore exceptions and continue execution
- To immediately throw an exception when an error occurs
- To log exceptions without retrying
Correct Answer: Option 1
9. In the Circuit Breaker pattern, what happens when the circuit breaker is in the "Open" state?
- Requests are allowed to proceed
- Requests are automatically retried
- Requests are short-circuited and fail immediately
- The system logs the request without processing it
Correct Answer: Option 3
10. What is the primary purpose of the Fallback pattern in exception handling?
- To retry an operation
- To execute an alternative logic when the primary logic fails
- To log the exception and terminate the program
- To rethrow the exception to the caller
Correct Answer: Option 2
11. Which pattern does the following statement describe: It allows multiple handlers to process an exception in sequence until one handles it.
- Fallback pattern
- Retry pattern
- Circuit breaker pattern
- Chain of responsibility pattern
Correct Answer: Option 4
12. The Retry pattern often includes an exponential backoff strategy. What does exponential backoff mean?
- Retrying immediately after a failure
- Increasing the delay between retries exponentially with each failure
- Reducing the delay between retries exponentially with each failure
- Retrying a fixed number of times without delay
Correct Answer: Option 2
13. What is the benefit of using exception assertions in unit tests?
- They ensure the application runs faster
- They make code easier to read
- They improve code indentation
- They confirm that code behaves as expected when an error occurs
Correct Answer: Option 4
14. When testing for exceptions, what is a common practice to verify exception properties?
- Catching the exception and asserting its properties
- Ignoring the exception properties
- Only testing the exception type
- Only testing if the exception is thrown
Correct Answer: Option 1
15. What type of exception should be thrown to indicate an invalid parameter passed to a method?
- NullReferenceException
- IndexOutOfRangeException
- ArgumentException
- IOException
Correct Answer: Option 3