Recall & Review
beginner
What is the main purpose of exception handling in C#?
Exception handling helps manage errors during program execution, allowing the program to continue running or exit gracefully instead of crashing.
Click to reveal answer
beginner
What happens if exceptions are not handled in a program?
If exceptions are not handled, the program may stop abruptly, causing a poor user experience and possible data loss.
Click to reveal answer
intermediate
How does exception handling improve program reliability?
By catching and managing errors, exception handling prevents unexpected crashes and allows the program to respond properly to problems.
Click to reveal answer
beginner
What keywords are used in C# for exception handling?
The main keywords are try, catch, finally, and throw.
Click to reveal answer
intermediate
Why is it important to handle exceptions close to where they occur?
Handling exceptions near their source helps provide specific fixes or messages and prevents errors from spreading through the program.
Click to reveal answer
What does exception handling primarily prevent in a program?
✗ Incorrect
Exception handling prevents program crashes by managing errors during execution.
Which keyword in C# is used to define a block of code to test for exceptions?
✗ Incorrect
The try block contains code that might throw an exception.
What is the role of the catch block in exception handling?
✗ Incorrect
The catch block handles exceptions thrown in the try block.
Why might a finally block be used in exception handling?
✗ Incorrect
The finally block runs code after try and catch blocks, no matter what.
What is a common consequence of not handling exceptions in a program?
✗ Incorrect
Without handling exceptions, the program may terminate unexpectedly.
Explain why exception handling is important in programming.
Think about what happens when errors occur during running a program.
You got /4 concepts.
Describe the roles of try, catch, and finally blocks in C# exception handling.
Consider how each block helps manage errors and program flow.
You got /3 concepts.