C# - Ch 11

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

An exception of the ____ class is thrown when an attempt is made to store an element of the wrong type within an array. a. System.ArrayTypeMismatchException b. System.ArithmeticException c. System.FormatException d. System.InvalidCastException

A

Any error condition or unexpected behavior in an executing program is known as an ___________. a. exception b. anomaly c. exclusion d. omission

A

In object-oriented terminology, a method that detects an error condition ___________ an Exception. a. throws b. catches c. tries d. unearths

A

The system of passing an exception through a chain of calling methods is called ____ the exception. a.propagating b.tracing c.stacking d.inheriting

A

When you catch an Exception, you can print the value of the ____ property to display a list of methods in the call stack so you can determine the location of the Exception. a.StackTrace b.CallTrace c.MethodTrace d.ClassTrace

A

When you write a block of code in which something can go wrong, you can place the code in a(n) ____ block. a. try b. catch c. exception d. finally

A

When you write a block of code in which something can go wrong, you can place the code in a(n) ____ block. a. try b. catch c. finally d. exception

A

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

A

You can terminate an application with the ____ method. a.Environment.Exit() b.Environment.Bye() c.Environment.Quit() d.Environment.Terminate()

A

Consider the following catch blocks. The variable b has been initialized to 0. If a DivideByZeroException occurs in a try block just before this catch block, what is the value of b when this code completes? catch(DivideByZeroException e) { ++b; } catch(Exception e) { ++b; } a. 0 b. 1 c. 2 d. 3

B

Each ____ block can "catch" one type of Exception. a. finally b. catch c. try d. Exception

B

If your program throws an IndexOutOfRangeException and the only available catch block catches an Exception, ___________. a. an IndexOutOfRangeException catch block is generated automatically b. the Exception catch block executes c. the Exception catch block is bypassed d. the IndexOutOfRangeException is thrown to the operating system

B

In C#, all exceptions are objects that are members of the ____ class or one of its derived classes. a. ApplicationException b. Exception c. SystemException d. RuntimeException

B

Most exceptions you will use derive from three classes: ___________. a. Object, ObjectException, and ObjectApplicationException b. Exception, SystemException, and ApplicationException c. FormatException, ApplicationException, and IOException d. SystemException, IOException, and FormatException

B

The Exception class contains a read-only property named ____ that contains useful information about an Exception object. a.StackTrace b.Message c.toString d.ThrownText

B

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

B

When a program creates an Exceptionobject, you ___________. a. must handle it b. can handle it c. must not handle it d. none of these; programs cannot create Exceptions

B

When you design your own classes that might cause exceptions, and other classes will use your classes as clients, you should usually create your methods to ___________. a. neither throw nor handle exceptions b. throw exceptions but not handle them c. handle exceptions but not throw them d. both throw and handle exceptions

B

Which of the following catch blocks will catch any Exception a. catch(Any e) {} b. catch(Exception e) {} c. catch(e) {} d. All of the above will catch any Exception.

B

Which of the following is not treated as a C# Exception? a. Your program asks the user to input a number, but the user enters a character. b. You attempt to execute a C# program, but the C# compiler has not been installed. c. You attempt to access an array with a subscript that is too large. d. You calculate a value that is too large for the answer's variable type.

B

A catch block executes when its try block ___________. a. completes b. throws any Exception c. throws an Exception of an acceptable type d. completes without throwing anything

C

An exception of the ____ class is thrown when an attempt is made to store an element of the wrong type within an array. a. System.ArithmeticException b. System.InvalidCastException c. System.ArrayTypeMismatchException d. System.FormatException

C

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

C

Consider the following catch blocks. The variable c has been initialized to 0. If an IndexOutOfRangeException occurs in a try block just before this catch block, what is the value of c when this code completes? catch(IndexOutOfRangeException e) { ++c; Because x is greater than 10, the Exception is thrown and the try block never executes the last two statements coded within it. } catch(Exception e) { ++c; } finally { ++c; } a. 0 b. 1 c. 2 d. 3

C

Consider the following try block. If x is 15, what is the value of a when this code completes? try { a = 99; if(x > 10) throw(new Exception()); a = 0; ++a; } a. 0 b. 1 c. 99 d. undefined

C

Exception objects can be ___________. a. generated automatically by C# b. created by a program c. both of these d. neither of these

C

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()

C

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

C

The ____ methods are used to convert string data to another data type, such as int, double, or bool, without fear of generating an exception. a.TryData() b.TryFromString() c.TryParse() d.TryConvert()

C

The creators of C# define an infrequent event in code as one that happens in less than ____ percent of all program executions. a.10 b.25 c.30 d.35

C

The memory location where the computer stores the list of locations to which the system must return is known as the ____. a.method call b.memory call c. call stack d.function call

C

Typically, you use a ____ to provide descriptive text for another Control object. a. ListBox b. Button c. CheckBox d. Label

D

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

D

When a user interacts with a GUI object, a(n) ____ is generated that causes the program to perform a task. Select one: a. trigger b. incall c. callback d. event

D

When you create an Exception subclass of your own, you should extend the ___________ class. a. SystemException The first catch block executes, increasing c from 0 to 1, then the finally block executes, increasing c from 1 to 2. b. PersonalException c. OverloadedException d. Exception

D

When you write a block of code in which something can go wrong, and you want to throw an Exception if it does, you place the code in a ___________ block. a. catch b. blind c. system d. try

D

Which of the following is valid within a catch block with the header catch(Exception error)? a. Console.WriteLine(error.ToString()); b. Console.WriteLine(error.Message); c. return(error.ToString()); d. two of these

D

You can place ___________ statement(s) within a try block. a. zero b. one c. two d. any number of

D

____ 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

D

____ is the type of exception automatically generated if there is a problem opening a file, reading data from a file, or writing to a file. a.FileException b.StorageException c.FException d.IOException

D

____ 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

D

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

F

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

F

T or F C# has more than 100 defined Exception subclasses.

T

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

T

T or F You can place any number of statements in a try block, including those you know will never throw an exception.

T

When you catch an Exception, you can print the value of the ____ property to display a list of methods in the call stack so you can determine the location of the Exception. a. ClassTrace b. MethodTrace c. StackTrace d. CallTrace

C

How many catch blocks might follow a try block within the same method? a. only one b. any number as long as it is greater than zero c. any number as long as it is greater than one d. any number, including zero or one

D

If you do not use object-oriented techniques, ___________. a. there are no error situations b. you cannot manage error situations c. you can manage error situations, but with great difficulty d. you can manage error situations

D

In object-oriented terminology, you ___________ a procedure that may not complete correctly. a. circumvent b. attempt c. catch d. try

D

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

D


संबंधित स्टडी सेट्स

Mental Health Exam 2 Study Guide

View Set

ECO 240 Ch 14: The Business Case for Environmental Sustainability

View Set

Ch. 5 Security - Adaptive Learning Assignment

View Set

PNU 133 Honan PrepU Collaboration / Teamwork & Collaboration

View Set

Chapter 30: Abdominal & Genital Injuries

View Set

FUNDS II Chapter 4. Nursing Process: Diagnosis

View Set

Health Online- GROWTH, DEVELOPMENT, AND SEXUAL HEALTH- Personal Hygiene and Health

View Set