Filters
Question type

Study Flashcards

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

Correct Answer

verifed

verified

False

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

Correct Answer

verifed

verified

Most exceptions will derive from three c...

View Answer

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


A) System
B) Application
C) CLR
D) Object

Correct Answer

verifed

verified

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


A) default
B) always
C) execute
D) finally

Correct Answer

verifed

verified

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


A) execute
B) always
C) finally
D) default

Correct Answer

verifed

verified

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


A) Fault tolerance
B) Mission critical
C) Forgiveness
D) Robustness

Correct Answer

verifed

verified

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


A) System.InvalidOperationException
B) System.ArithmeticException
C) System.Data.OperationAbortedException
D) System.InvalidCastException

Correct Answer

verifed

verified

Match each item with a statement below:

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

Correct Answer

Used to rethrow an Exception
Performs clean-up tasks at the end of a try … catch sequence
Occurs when an array subscript is not within the allowed range
Exception class for when a user requests an invalid printer
Sometimes referred to as a catch clause
Thrown when one of the arguments provided to a method is not valid
Terminates a program and passes the argument (which can be any integer) to the operating system
Exception class for input and output errors
Also called dead code

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


A) Default
B) catch
C) finally
D) Unreachable

Correct Answer

verifed

verified

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.


A) rethrow
B) save
C) open
D) delete

Correct Answer

verifed

verified

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


A) SystemException
B) Exception
C) ObjectException
D) MainException

Correct Answer

verifed

verified

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?

Correct Answer

verifed

verified

The example code represents the most eff...

View Answer

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

Correct Answer

verifed

verified

System.Inv...

View Answer

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?

Correct Answer

verifed

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 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.


A) Message()
B) StackTrace()
C) ToString()
D) ThrownMessage()

Correct Answer

verifed

verified

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

Correct Answer

verifed

verified

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.

Correct Answer

verifed

verified

The method should be similar to the foll...

View Answer

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?

Correct Answer

verifed

verified

Handling an exception can be l...

View Answer

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

Correct Answer

verifed

verified

exception handling

You can terminate an application with the ____ method.


A) Environment.Exit()
B) Environment.Bye()
C) Environment.Quit()
D) Environment.Terminate()

Correct Answer

verifed

verified

Showing 1 - 20 of 42

Related Exams

Show Answer