Chapter 19

Answers to Chapter 19 Review Questions

1: List three examples of typical exceptions.
A1: Dividing by zero, running out of memory, accessing a non-existent file.
2: What are the advantages of handling exceptions with try-catch-finally?
A2: The normal case code and exception handling code can be kept separate. Exceptions can be handled gracefully without exposing the end user to cryptic looking code.
3: Which class is at the top of the exceptions class hierarchy?
A3: System.Exception
4: How many catch and finally blocks can be attached to a try block?
A4: Zero, one or many catch blocks, and zero or one finally block. However, at least one block (it can either be a catch or a finally block) must be attached to a try block.
5: What happens to ...

Get C# Primer Plus now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.