Welcome to the C# Exception Handling Quiz! This quiz is designed to test your understanding of how C# manages exceptions, including how they are thrown, caught, and handled using try-catch blocks. You will also encounter questions about creating custom exceptions, using the finally block, and implementing exception filters. The quiz will challenge your knowledge of best practices for handling runtime errors in C# and ensure you’re prepared to write robust, error-resistant code.
1.
What does the 'base' keyword do in a custom exception class?
2.
How does an exception filter help in handling exceptions?
3.
What does the 'inner' parameter in an exception constructor represent?
4.
What is the primary purpose of a custom exception constructor?
5.
Why would you create a custom exception?
6.
Which of the following methods is used to re-throw an exception?
7.
How can multiple exceptions be caught in C#?
8.
What does 'try-finally' ensure?
9.
Which keyword allows you to define a clean-up operation, regardless of whether an exception occurs?
10.
What happens when an exception is not caught in any method in the call hierarchy?
11.
Which keyword is used to throw an exception in C#?
12.
What does the 'finally' block guarantee?
14.
What is the effect of calling 'throw;' inside a catch block?
15.
What is the purpose of exception handling in C#?
16.
Why might you create a custom exception in C#?
17.
Which statement correctly re-throws an exception caught in a catch block?
18.
How do you access the exception message in a catch block?
19.
What will happen if an exception is thrown inside a method but not caught in the same method?
20.
Which of the following best describes exception filters using the 'when' keyword?
21.
Which of the following is TRUE about a 'catch' block?
22.
In a try-catch block, what does the 'try' section do?
23.
What is the role of the 'throw' keyword in C#?
24.
Which of the following is a built-in exception type in C#?
25.
What happens when an exception is thrown in C#?