Chapter 12
C# Programming: From Problem Analysis to Program Design · 20 exercises
Problem 1
___________are unexpected conditions that happen very infrequently. a. Bugs b. Conditions c. Exceptions d. Streams e. Objects
3 step solution
Problem 2
A Just-In-Time Debugging window is displayed when a(an): a. application is executed b. unhandled exception is thrown c. handled exception is thrown d. unhandled exception is caught e. handled exception is caught
4 step solution
Problem 3
Raising an exception is the same as: a. catching an exception b. trying a block of code that might create an exception c. throwing an exception d. defining a new exception class e. rolling back an exception
5 step solution
Problem 4
The segment of code that might create an unexpected problem should be: a. placed in a try block b. placed in a catch block c. placed in a finally block d. placed on the outside of the try...catch...finally block e. included in the Main( ) method
6 step solution
Problem 5
What type of exception would be thrown if the user enters the wrong type of data when requested from the keyboard? a. System. FormatException b. System. Invalid. CastException c. System. NullReferenceException d. System. IndexoutofRangeException e. System. ArithmeticException
3 step solution
Problem 7
What type of exception would be thrown if the following arithmetic were performed? \\[ \begin{aligned} \text { double avalue } &=0 \\ \text { bvalue } &=0 \end{aligned} \\] int result \(=(\text { int })\) avalue / \((\) int ) bvalue a. System. FormatException b. System. Invalid. CastException c. System. ArgumentException d. System. DivideByzeroException e. none of the above
3 step solution
Problem 8
If an application is written to filter several exceptions including System. Exception, System.DivideByZeroException, and System. ArithmeticException, in what order should they be listed? a. System. Exception, System. DivideByzeroException, then System. ArithmeticException b. System. Exception, System. ArithmeticException, then System. DivideByzeroException c. System. DivideByzeroException, System. Exception, then System. ArithmeticException d. System. DivideByzeroException, System. ArithmeticException, then System . Exception e. It does not matter.
4 step solution
Problem 9
To avoid an exception with files, you can use a try... catch block and include which exception class in your catch clause? a. File.ExistsException b. IOException c. FileException d. ExceptionFile e. none of the above
4 step solution
Problem 10
Writing a catch clause without including the parentheses and an argument list such as catch \\{\\}: a. generates a syntax error b. requires a finally clause c. has the same effect as catch (System.Exception) \\{\\} d. throws an exception e. none of the above
4 step solution
Problem 11
Two major types of errors found in programs are: a. compiler and syntax b. compiler and exceptions c. logic and grammar d. compiler and run-time e. exceptions and logic
4 step solution
Problem 12
___________errors are the easiest to discover and correct. a. Exception b. Compiler c. \(R\) un-time d. Logic e. Omission
3 step solution
Problem 13
Language Specifications are: a. the authoritative source for C# grammar b. the specifications that detail information on all aspects of the language c. the authoritat… # C# Language Specifications are: a. the authoritative source for C# grammar b. the specifications that detail information on all aspects of the language c. the authoritative source for C# syntax d. available for a free download e. all of the above
3 step solution
Problem 14
The Debugger can be used to: a. observe syntax errors b. rewrite the grammar for the program c. review what the output should be d. step through an application e. none of the above
6 step solution
Problem 15
A marker that is placed in an application, indicating the program should halt execution when it reaches that point, is called a(n): a. exception b. debugger c. watch d. pause e. breakpoint
3 step solution
Problem 16
If a method throws an exception and the exception is not caught inside the method: a. The program automatically crashes. b. The rest of the program is executed, but the program statement(s) that caused the problem is skipped. c. An exception is thrown. d. The method execution returns to the first line in the method. e. none of the above
3 step solution
Problem 17
Which of the following lines contains information regarding a thrown exception named e? a. e. Message b. e. ExceptionType c. e. ExceptionInfo d. e. ExceptionMessage e. e. Information
3 step solution
Problem 18
The Debugger in Visual Studio offers all of the following options for stepping, except: a. Step Into b. Step Over c. Step Out d. Step Through e. none of the above
4 step solution
Problem 20
The ApplicationException class is derived from: a. System b. SystemException c. System. Exception d. ExceptionApplication e. Exception
4 step solution
Problem 21
The result of division by zero is undefined for both integral and floating- point values. Describe how avoiding floating-point division by zero differs from integral division by zero.
4 step solution
Problem 22
Give one example of what would cause each of the following exceptions to be thrown: a. System. ArithmeticException b. System. FormatException c. System. Indexoutof RangeException
3 step solution