Deck 11: Exception Handling

ملء الشاشة (f)
exit full mode
سؤال
Errors you discover when compiling a program are considered to be exceptions.
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
All classes in the C# programming language, including the Exception class, are descendants of what built in class?

A) System
B) Application
C) CLR
D) Object
سؤال
In general, what block do you use to perform clean-up tasks that must occur, regardless of whether any errors occurred or were caught?

A) default block
B) always block
C) execute block
D) finally block
سؤال
You can deliberately generate a SystemException by forcing a program to contain an error.
سؤال
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
سؤال
What represents the degree to which a system is resilient to stress and able to maintain correct functioning?

A) fault tolerance
B) critical functionality
C) load forgiveness
D) system robustness
سؤال
What method can be used to terminate an application?

A) Environment.Exit()
B) Environment.Bye()
C) Environment.Quit()
D) Environment.Terminate()
سؤال
What read-only property in the Exception class contains useful information about an Exception object?

A) StackTrace
B) Message
C) toString
D) ThrownText
سؤال
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.
سؤال
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%
سؤال
A catch block can catch how many types of Exceptions?

A) An unlimited number of Exception types.
B) Only one can be caught.
C) As many as can be matched.
D) Two, after which the program ends.
سؤال
In C#, all exceptions are objects that are members or derived members of what specific class?

A) ApplicationException
B) Exception
C) SystemException
D) RuntimeException
سؤال
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()
سؤال
An exception belonging to what specific class is thrown when an attempt is made to store an element of the wrong type within an array?

A) System.ArrayTypeMismatchException
B) System.TypeMismatch
C) System.FormatException
D) System.InvalidCastException
سؤال
You can place any number of statements in a try block, including those you know will never throw an exception.
سؤال
What 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()
سؤال
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
سؤال
What block can you use to ensure that input and output related files are properly closed?

A) execute
B) always
C) finally
D) default
سؤال
C# has more than 100 defined Exception subclasses.
سؤال
If you are working on a professional project, Microsoft recommends that you use the general Exception class in a catch block.
سؤال
The StackTrace property of an Exception can be a useful debugging tool.How is this property used when debugging?
سؤال
The ApplicationException class is a sublcass of what other class?

A) SystemException
B) Exception
C) ObjectException
D) MainException
سؤال
What class should you extend in order to create your own Exception that you can throw?

A) ApplicationException
B) ExceptionObject
C) SystemException
D) Object
سؤال
When creating an Exception class, what is not one of the three recommended constructors needed?

A) A default constructor.
B) A constructor that takes a string message.
C) A constructor that takes a string message and an inner exception.
D) A constructor that takes a byte variable containing memory dumps.
سؤال
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?
سؤال
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.
سؤال
When you catch an Exception, what property holds a list of methods in the call stack as its value, allowing you to determine the location of the Exception?

A) StackTrace
B) CallTrace
C) MethodTrace
D) ClassTrace
سؤال
The Environment.Exit() method is part of what namespace?

A) Exception
B) System
C) Quit
D) Language
سؤال
Most exceptions that are used by programmers derive from three C# classes.What are those classes?
سؤال
What type of exception is thrown if there is an issue with file operations, such as opening, reading from, or writing to a file?

A) FileException
B) StorageException
C) FException
D) IOException
سؤال
When an Exception object is thrown and multiple catch blocks are present, what happens?
سؤال
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?
سؤال
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
سؤال
Show the syntax (the general form) of a try…catch pair.
سؤال
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?
سؤال
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.
سؤال
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
سؤال
The memory location where the computer stores the list of locations to which the system must return is known by what term?

A) The method call trace.
B) The memory call pool.
C) The call stack.
D) The function call.
سؤال
Why might a finally block be necessary?
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/39
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 11: Exception Handling
1
Errors you discover when compiling a program are considered to be exceptions.
False
2
All classes in the C# programming language, including the Exception class, are descendants of what built in class?

A) System
B) Application
C) CLR
D) Object
D
3
In general, what block do you use to perform clean-up tasks that must occur, regardless of whether any errors occurred or were caught?

A) default block
B) always block
C) execute block
D) finally block
D
4
You can deliberately generate a SystemException by forcing a program to contain an error.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
5
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
6
What represents the degree to which a system is resilient to stress and able to maintain correct functioning?

A) fault tolerance
B) critical functionality
C) load forgiveness
D) system robustness
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
7
What method can be used to terminate an application?

A) Environment.Exit()
B) Environment.Bye()
C) Environment.Quit()
D) Environment.Terminate()
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
8
What read-only property in the Exception class contains useful information about an Exception object?

A) StackTrace
B) Message
C) toString
D) ThrownText
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
9
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
10
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%
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
11
A catch block can catch how many types of Exceptions?

A) An unlimited number of Exception types.
B) Only one can be caught.
C) As many as can be matched.
D) Two, after which the program ends.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
12
In C#, all exceptions are objects that are members or derived members of what specific class?

A) ApplicationException
B) Exception
C) SystemException
D) RuntimeException
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
13
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()
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
14
An exception belonging to what specific class is thrown when an attempt is made to store an element of the wrong type within an array?

A) System.ArrayTypeMismatchException
B) System.TypeMismatch
C) System.FormatException
D) System.InvalidCastException
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
15
You can place any number of statements in a try block, including those you know will never throw an exception.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
16
What 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()
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
17
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
18
What block can you use to ensure that input and output related files are properly closed?

A) execute
B) always
C) finally
D) default
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
19
C# has more than 100 defined Exception subclasses.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
20
If you are working on a professional project, Microsoft recommends that you use the general Exception class in a catch block.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
21
The StackTrace property of an Exception can be a useful debugging tool.How is this property used when debugging?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
22
The ApplicationException class is a sublcass of what other class?

A) SystemException
B) Exception
C) ObjectException
D) MainException
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
23
What class should you extend in order to create your own Exception that you can throw?

A) ApplicationException
B) ExceptionObject
C) SystemException
D) Object
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
24
When creating an Exception class, what is not one of the three recommended constructors needed?

A) A default constructor.
B) A constructor that takes a string message.
C) A constructor that takes a string message and an inner exception.
D) A constructor that takes a byte variable containing memory dumps.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
25
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?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
26
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
27
When you catch an Exception, what property holds a list of methods in the call stack as its value, allowing you to determine the location of the Exception?

A) StackTrace
B) CallTrace
C) MethodTrace
D) ClassTrace
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
28
The Environment.Exit() method is part of what namespace?

A) Exception
B) System
C) Quit
D) Language
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
29
Most exceptions that are used by programmers derive from three C# classes.What are those classes?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
30
What type of exception is thrown if there is an issue with file operations, such as opening, reading from, or writing to a file?

A) FileException
B) StorageException
C) FException
D) IOException
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
31
When an Exception object is thrown and multiple catch blocks are present, what happens?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
32
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?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
33
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
34
Show the syntax (the general form) of a try…catch pair.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
35
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?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
36
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
37
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
38
The memory location where the computer stores the list of locations to which the system must return is known by what term?

A) The method call trace.
B) The memory call pool.
C) The call stack.
D) The function call.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
39
Why might a finally block be necessary?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.