This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
What does the try code block contain?
try
The code that cleans up resources and is executed whether an exception occurs or not.
The code that throws an exception object.
The code that may cause an exception.
What is the purpose of the catch code block?
catch
To clean up any resources that are allocated in a try block.
To handle the exception, log it, or ignore it.
To execute code that may cause an exception.
When is an IndexOutOfRangeException exception thrown?
IndexOutOfRangeException
An IndexOutOfRangeException exception is thrown when an attempt is made to store a value of one type in an array of another type.
An IndexOutOfRangeException exception is thrown when attempting an invalid casting or explicit conversion.
An IndexOutOfRangeException exception is thrown when an attempt is made to index an array outside the bounds of the array.
When is an ArrayTypeMismatchException exception thrown?
ArrayTypeMismatchException
An ArrayTypeMismatchException exception is thrown when an attempt is made to store a value of one type in an array of another type.
An ArrayTypeMismatchException exception is thrown when attempting to access a member on a type whose value is null.
An ArrayTypeMismatchException exception is thrown when an attempt is made to index an array outside the bounds of the array.
What is the name of the base class that all derived exception types inherit from?
Object.
Object
System.
System
Exception.
Exception
Which property of an exception object can be used to determine where an error occurred?
InnerException.
StackTrace.
TargetSite.
What is the recommended approach for catching exceptions in C#?
Catch any type of exception without specifying an object argument.
Catch only the exceptions that your code knows how to recover from.
Catch only the exceptions that are not derived from System.Exception.
What is the name of the specific exception type that occurs when attempting to divide by zero in C#?
ArithmeticException.
InvalidCastException.
DivideByZeroException.
You must answer all questions before checking your work.
Was this page helpful?