Filters
Question type

Study Flashcards

Why might a finally block be necessary?

Correct Answer

verifed

verified

At first glance, it seems as though the ...

View Answer

Errors you discover when compiling a program are considered to be exceptions.

Correct Answer

verifed

verified

When an Exception object is thrown and multiple catch blocks are present, what happens?

Correct Answer

verifed

verified

When an Exception is thrown and multiple...

View Answer

In C#, all exceptions are objects that are members or derived members of what specific class?


A) ApplicationException
B) Exception
C) SystemException
D) RuntimeException

Correct Answer

verifed

verified

B

What method is overridden by the Exception class in order to provide a descriptive error message and provide a user with precise information about the nature of any Exception that is thrown?


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

Correct Answer

verifed

verified

What class should you extend in order to create your own Exception that you can throw?


A) ApplicationException
B) ExceptionObject
C) SystemException
D) Object

Correct Answer

verifed

verified

What is the system of passing an exception through a chain of calling methods called?


A) propagating the exception
B) tracing the exception
C) stacking the exception
D) inheriting the exception

Correct Answer

verifed

verified

A

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

A block that contains statements that can never execute under any circumstances due to a program's logic is known as what kind of block?


A) default block
B) comment block
C) finally block
D) unreachable block

Correct Answer

verifed

verified

You can deliberately generate a SystemException by forcing a program to contain an error.

Correct Answer

verifed

verified

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

When you write a method that catches an Exception, rather than handling the Exception itself, it can pass the exception to the method that called your method.What is this known as?


A) rethrowing the Exception
B) saving the Exception
C) opening the Exception
D) sideloading the Exception

Correct Answer

verifed

verified

A

Show the syntax (the general form) of a try…catch pair.

Correct Answer

verifed

verified

try
{
// Any number of statements;
// so...

View Answer

According to the creators of C#, an infrequent event in code is one that happens in less than what percent of all program executions?


A) 10%
B) 25%
C) 30%
D) 35%

Correct Answer

verifed

verified

When writing a block of code in which something can go wrong, where should you place the block?


A) It should be placed in a try block.
B) It should be placed after a catch statement.
C) It should be prefaced with a finally statement.
D) It should be defined as an exception block.

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

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

The Environment.Exit() method is part of what namespace?


A) Exception
B) System
C) Quit
D) Language

Correct Answer

verifed

verified

The ApplicationException class is a sublcass of what other class?


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

Correct Answer

verifed

verified

What happens when you divide a floating-point value by 0 in C#?


A) No exception occurs, and the special value Infinity is returned as the result.
B) The program will throw an exception of type System.DivideByZeroException.
C) The program will catch the exception, and return Undefined as the result.
D) The program will crash.

Correct Answer

verifed

verified

Showing 1 - 20 of 39

Related Exams

Show Answer