Exam 11: Exception Handling

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

If a finally block is associated with a try … catch pair, what are the three possible outcomes of the try that result in execution of the finally block?

Free
(Essay)
4.9/5
(29)
Correct Answer:
Verified

The code in the finally block executes no matter which of the following outcomes of the try block occurs:
* The try ends normally.
* The catch executes.
* The try ends abnormally and the catch does not execute.

The object-oriented techniques used to manage errors make up the group of methods known as ____________________.

Free
(Short Answer)
4.8/5
(42)
Correct Answer:
Verified

exception handling

If you are working on a professional project, Microsoft recommends that you use the general Exception class in a catch block.

Free
(True/False)
4.7/5
(33)
Correct Answer:
Verified

False

____ blocks contain statements that can never execute under any circumstances because the program logic "can't get there."

(Multiple Choice)
4.9/5
(42)

The ____ block is used frequently with file input and output to ensure that open files are closed.

(Multiple Choice)
4.8/5
(44)

To create your own Exception that you can throw, you can extend the ApplicationException class, which is a subclass of ____.

(Multiple Choice)
4.9/5
(35)
Match each item with a statement below:
Used to rethrow an Exception
Environment.Exit()
Performs clean-up tasks at the end of a try … catch sequence
unreachable code
Occurs when an array subscript is not within the allowed range
IOException
Correct Answer:
Verified
Premises:
Responses:
Used to rethrow an Exception
Environment.Exit()
Performs clean-up tasks at the end of a try … catch sequence
unreachable code
Occurs when an array subscript is not within the allowed range
IOException
Exception class for when a user requests an invalid printer
InvalidPrinterException
Sometimes referred to as a catch clause
System.ArgumentException
Thrown when one of the arguments provided to a method is not valid
catch block
Terminates a program and passes the argument (which can be any integer) to the operating system
finally block
Exception class for input and output errors
throw
Also called dead code
IndexOutOfRangeException
(Matching)
4.7/5
(48)

When you design classes containing methods that have statements that might throw exceptions, you can create the methods so they throw the Exception object but do not handle it. Why might you want to do this?

(Essay)
4.8/5
(31)

When you write a method that catches an Exception , your method does not have to handle it. Instead, you might choose to ____ the exception to the method that called your method.

(Multiple Choice)
4.8/5
(29)

The Exception class overrides ____ to provide a descriptive error message so a user can receive precise information about the nature of any Exception that is thrown.

(Multiple Choice)
4.7/5
(38)

An exception of the ____ class is thrown when an ongoing operation is aborted by the user.

(Multiple Choice)
5.0/5
(39)

____ represents the degree to which a system is resilient to stress and able to maintain correct functioning.

(Multiple Choice)
4.9/5
(38)

Like all other classes in the C# programming language, the Exception class is a descendant of the ____ class.

(Multiple Choice)
4.7/5
(35)

An exception of class _____________________________________________ is thrown when a method call is invalid for the object's current state.

(Short Answer)
4.9/5
(46)

Most exceptions that are used by programmers derive from three C# classes. What are those classes?

(Essay)
4.9/5
(46)

Typically, you use the ____ block to perform clean-up tasks that must occur, regardless of whether any errors occurred or were caught.

(Multiple Choice)
5.0/5
(39)

The int version of the TryParse() methods converts string data to an int . The first argument is the string that you want to convert, and the second argument is an out parameter that receives the result if the conversion is successful, or 0 if it is not. The method returns a Boolean value that indicates whether the conversion was successful. Write this method using exception handling techniques to ensure that the method returns correctly whether or not the conversion is successful. Use the method Convert.ToInt32(inputString) to do the conversion.

(Essay)
4.9/5
(48)

The term ____________________ refers to any process that is crucial to an organization.

(Short Answer)
4.8/5
(31)

You can terminate an application with the ____ method.

(Multiple Choice)
4.8/5
(36)

The following example shows how a programmer might avoid a division by zero error by explicitly checking for the error condition: if (gallonsOfGas != 0) mpg = milesDriven /gallonsOfGas; else mpg = 0; Another possible way to deal with this is to use exception handling mechanisms. What factors help the programmer decide which of these methods to use?

(Essay)
4.8/5
(39)
Showing 1 - 20 of 42
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)