Name: Class: Date: Chapter 6 Test Bank True/False Indicate whether the statement is true or false. 1. You might be able to write statements using the correct syntax, but be unable to construct an entire, logically executed program that works the way you want. 2. Today, a bug refers to any sort of problem in the design and operation of a program. 3. Syntax errors can be caused by incorrect logic or references to objects, methods, and variables that do not exist. 4. Logic errors generate compiler errors. 5. Some compiler error messages do not exactly identify the cause of a compiler error. 6. Run-time errors differ from syntax errors in that they do not necessarily represent C# language errors. 7. To print detailed information about errors to the browser window for a particular Web page, you need to include the Error attribute in the @ Page directive and assign it a value of true. 8. When you are unable to locate a bug in your program by using error messages or examining your code, or if you suspect a logic error, you can try tracing your code manually. 9. The key to using multiple Response.Write() statements to trace program values is using them selectively at key points throughout a program. 10. When you first receive an error message or your program doesn t work as expected, start by commenting out all of the statements surrounding those specified by the line number in the error message. 11. When searching for errors, it s often helpful to combine debugging techniques. 12. When you suspect that your code contains logic errors, you must analyze each statement on a case-by-case basis. 13. With diagnostic tracing, you must always remove any Trace.Write() and Trace.Warn() methods from your code before deploying your application. 14. When you first enter break mode, two new windows, Locals and Watch, appear at the bottom of the Visual Studio IDE. 15. You can make changes to code in break mode that will take effect while the program is executing. 16. To open the Immediate window, point to Windows on the Debug menu and then click Immediate. 17. The term bulletproofing indicates that something unexpected occurred while a program is running. 1
Name: 18. The exception objects that are thrown from a try statement contain several properties and methods that describe what went wrong. 19. A catch statement is constructed with one or more parameters of the thrown exception type. 20. If the thrown exception is within a try block, the compiler checks the catch block for an additional try statement. 21. Your goal as a good ASP.NET programmer is to prevent visitors to your Web site from seeing the default error page, which can be extremely confusing to nonprogrammers. 22. A try statement can only contain one catch block. 23. The most basic method of handling errors at the page level is to assign an error page to the ErrorPage attribute of the @ Page directive. 24. The statements that you use to handle errors at the application level are the same as the page level. 25. You can include Response.Write() and other types of output statements in the Global.asax file. Multiple Choice Identify the choice that best completes the statement or answers the question. 26. All programming languages, including C#, have their own, or rules. a. protocols c. semantics b. syntax d. structure 27. The term refers to the order in which various parts of a program run, or execute. a. algorithm c. logic b. structure d. reason 28. Any error in a program that causes it to function incorrectly, whether because of incorrect syntax or flaws in logic, is called a. a. bug c. flaw b. feature d. splinter 29. The term refers to the act of tracing and resolving errors in a program. a. decoding c. deciphering b. debugging d. displacing 30. occur when the interpreter fails to recognize code. a. Runtime errors c. Logic errors b. Link errors d. Syntax errors 31. The statement response.write("hello World"); causes a syntax error because. a. the Response object is incorrectly typed with a lowercase r b. the statement should be write.response c. the literal should be in single quotes d. there is no such method as write for the response object 2
Name: 32. are flaws in a program s design that prevent the program from running as you anticipate. a. Syntax errors c. Logic errors b. Link errors d. Runtime errors 33. To trace a problem, you can place a statement at the point in the program where you think the error might be located. a. Response.Console() c. Response.Log() b. Response.Write() d. Response.Print() 34. A is a simplified, temporary program that is used for testing functions and other code. a. loader program c. bootstrap program b. stripped program d. driver program 35. are empty functions that serve as placeholders for a program s actual functions. a. Null functions c. Void functions b. Stub functions d. Rough functions 36. The window displays all local variables within the currently executing function, regardless of whether they have been initialized. a. Locals c. Immediate b. Globals d. Watch 37. The monitors both variables and expressions in break mode. a. Locals window c. Watch window b. Globals window d. Immediate window 38. You can use the window to monitor specific variables and expressions in break mode. a. Locals c. Watch b. Global d. Immediate 39. The term call refers to the order in which procedures, such as functions, methods, or event handlers, execute in a program. a. heap c. block b. stack d. queue 40. Writing code that anticipates and handles potential problems is often called. a. compensating c. hardening b. restructuring d. bulletproofing 41. The process by which a try statement generates an exception class object is referred to as. a. throwing an exception c. popping an assertion b. asserting d. popping the stack 42. You can manually throw an exception by using a(n) statement and an Exception object. a. assert c. throw b. handle d. catch 43. After you throw an error, you use a(n) statement to handle the exception object. a. catch c. assert b. throw d. handle 3
Name: 44. The exception-handling functionality in C# also includes a(n) statement that executes regardless of whether its associated try block throws an exception. a. allelse c. else b. finally d. allothers 45. To redirect the Web browser to an error page from an error event handler, you must pass the name of the page to the method. a. System.Redirect() c. System.Transpose() b. System.Rewrite() d. System.Transfer() 46. To pass an error to a page error event handler, you must throw it from the. a. object level c. code level b. system level d. server level 47. You use the method to redirect users to a generic error page. a. System.Transfer() c. System.ClearError() b. System.LastError() d. Server.Transfer() 48. You use the method to clear errors. a. System.Transfer() c. Server.ClearError() b. System.ClearError() d. Server.Clear() 49. You use the method to access the last exception that occurred. a. System.LastError() c. System.GetLastError() b. Server.GetLastError() d. Server.LastError() 50. Unlike page error event handlers, application errors are handled in the file, which contains event handlers for handling application events. a. Master.asax c. Global.aspx b. Default.aspx d. Global.asax 4
Chapter 6 Test Bank Answer Section TRUE/FALSE 1. ANS: T PTS: 1 REF: 310 2. ANS: T PTS: 1 REF: 310 3. ANS: F PTS: 1 REF: 310 4. ANS: F PTS: 1 REF: 311 5. ANS: T PTS: 1 REF: 311 6. ANS: T PTS: 1 REF: 314 7. ANS: F PTS: 1 REF: 317 8. ANS: T PTS: 1 REF: 320 9. ANS: T PTS: 1 REF: 322 10. ANS: F PTS: 1 REF: 324 11. ANS: T PTS: 1 REF: 327 12. ANS: T PTS: 1 REF: 328 13. ANS: F PTS: 1 REF: 332 14. ANS: T PTS: 1 REF: 335 15. ANS: F PTS: 1 REF: 336 16. ANS: T PTS: 1 REF: 341 17. ANS: F PTS: 1 REF: 345 18. ANS: T PTS: 1 REF: 346 19. ANS: F PTS: 1 REF: 347 20. ANS: F PTS: 1 REF: 347 21. ANS: T PTS: 1 REF: 347 22. ANS: F PTS: 1 REF: 348 23. ANS: T PTS: 1 REF: 350 24. ANS: T PTS: 1 REF: 351 25. ANS: F PTS: 1 REF: 352 MULTIPLE CHOICE 26. ANS: B PTS: 1 REF: 310 27. ANS: C PTS: 1 REF: 310 28. ANS: A PTS: 1 REF: 310 29. ANS: B PTS: 1 REF: 310 30. ANS: D PTS: 1 REF: 310 31. ANS: A PTS: 1 REF: 311 32. ANS: C PTS: 1 REF: 315 33. ANS: B PTS: 1 REF: 321 34. ANS: D PTS: 1 REF: 324 35. ANS: B PTS: 1 REF: 324 36. ANS: A PTS: 1 REF: 339 37. ANS: C PTS: 1 REF: 340 1
38. ANS: D PTS: 1 REF: 341 39. ANS: B PTS: 1 REF: 344 40. ANS: D PTS: 1 REF: 345 41. ANS: A PTS: 1 REF: 345 42. ANS: C PTS: 1 REF: 346 43. ANS: A PTS: 1 REF: 346 44. ANS: B PTS: 1 REF: 349 45. ANS: D PTS: 1 REF: 350 46. ANS: C PTS: 1 REF: 350 47. ANS: A PTS: 1 REF: 351 48. ANS: C PTS: 1 REF: 351 49. ANS: B PTS: 1 REF: 351 50. ANS: D PTS: 1 REF: 351 2
Chapter 6 Test Bank [Answer Strip] _ T 18. _ C 32. _ B 44. _ T 1. _ F 19. _ F 20. _ B 33. _ D 45. _ T 2. _ F 3. _ F 4. _ T 21. _ F 22. _ T 23. _ D 34. _ B 35. _ C 46. _ A 47. _ T 5. _ T 6. _ T 24. _ F 25. _ A 36. _ C 48. _ F 7. _ C 37. _ B 49. _ T 8. _ B 26. _ D 38. _ D 50. _ T 9. _ C 27. _ B 39. _ F 10. _ T 11. _ A 28. _ D 40. _ T 12. _ F 13. _ B 29. _ A 41. _ T 14. _ D 30. _ C 42. _ F 15. _ A 31. _ A 43. _ T 16. _ F 17.