Ch 3 review questions C#

¡Supera tus tareas y exámenes ahora con Quizwiz!

45. You cannot declare two variables with the same ____________ in the same scope. a. lifetime b. data type c. name d. value

C

51. When declaring multiple variables with one statement, use ____________ to separate the variable names. a. semicolons (;) b. underscores (_) c. asterisks (*) d. commas (,)

D

59. The process of dropping a real number's fractional part is called ____________. a. rounding b. diminution c. reduction d. truncation

D

65. When an operation is performed on two int values, the result will be a(n) ____________. a. decimal b. double c. string d. int

D

68. When a math expression involves an int and a double, the result will be a __________. a. int b. decimal c. string d. double

D

71. Please examine the following code sample: int distance; // Declare distance as an int double half; // Declare half as a double distance = 35; // Assign 35 to distance half = distance / 2; // Calculate half the distance What value is assigned to the half variable? a. 70 b. 17.5 c. 18 d. 17

D

11. If a statement in the try block throws an exception, the program immediately jumps to a ____________. a. catch block b. try block c. run block d. break block

A

12. When an exception is thrown, an object known as a(n) ____________ is created in memory. a. exception object b. debug variable c. try object d. state object

A

2. A ____________ is a number that is directly written into a program's code. a. numeric literal b. binary constant c. real value d. source digit

A

21. When an application is running, the control having the ____________ is the one that receives the user's keyboard input. a. focus b. scope c. data d. tab index

A

23. The ____________ property contains an integer value that indicates the control's position in the tab order. a. TabIndex b. FocusIdex c. OrderIndex d. IndexValue

A

26. When a user types something into a TextBox control, the input is stored in the control's ____________ property. a. Text b. Input c. String d. Value

A

27. The TextBox control is located in the ____________ group of the Toolbox. a. Common Controls b. Dialog c. Components d. Containers

A

31. A(n) ____________ specifies a variable's name and data type. a. variable declaration b. data indicator c. object tag d. source entity

A

38. The ____________ operator produces a string that is the combination of the two strings used as its operands. a. + b. = c. * d. &

A

4. Which one of the following statements initializes a variable with an integer literal? a. int score = 2500; b. decimal total = 156.78m; c. double rate = 0.00435; d. string name = "Michelle";

A

42. Programmers use the term ____________ to describe the part of a program in which a variable may be accessed. a. scope b. lifetime c. method d. accessibility

A

46. You can assign a value to a variable only if the value is compatible with the variable's ____________. a. data type b. name c. scope d. lifetime

A

48. When coding most statements, you can press the ____________ key when you reach an appropriate point to continue the statement on the next line. a. Enter b. Tab c. X d. Shift

A

49. One way to make sure a variable has been assigned a value is to ___________ the variable with a value when you declare it. a. initialize b. instantiate c. concatenate d. compare

A

52. Which one of the following statements declares the string variables city, state, and zip using a single declaration statement? a. string city, state, zip; b. string city, string state, string zip; c. string city; state; zip; d. string city_state_zip;

A

58. You can use a(n) ____________ to explicitly convert a value from one numeric data type to another, even if the conversion might result in a loss of data. a. cast operator b. conversion formula c. data binding d. explicit operator

A

61. A(n) ____________ contains operators, constants, and variables, and performs a calculation. a. math expression b. algorithm c. data utility d. variable

A

64. Parts of a mathematical expression may be grouped with ____________ to force some operations to be performed before others. a. parentheses b. double quotation marks c. braces d. semicolons

A

69. When a math expression involves an int and a decimal, the result will be a ___________. a. decimal b. double c. string d. int

A

75. The ____________ method can be used to convert a string to an int. a. int.Parse b. Parse.int c. Parse.ToString.int d. ToString.Parse.int

A

78. A data value (variable or constant) passed into a method is known as a(n) ____________. a. argument b. delimiter c. descriptor d. factor

A

80. In C#, all variables have a(n) ____________ method that you can call to convert the variable's value to a string. a. ToString b. Convert c. Parse d. Text

A

83. When you call the ToString method, you can optionally pass a(n) ____________ as an argument to the method to indicate that you want the number to appear formatted in a specific way when it is returned as a string from the method. a. formatting string b. style specifier c. output value d. design element

A

84. When you pass the formatting string ____________ to the ToString method, the number is returned formatted as currency. a. "C" or "c" b. "F" or "f" c. "E" or "e" d. "N" or "n"

A

88. ____________ ("P" or "p") causes the number to be multiplied by 100 and displayed with a trailing space and % sign. a. Percent format b. Currency format c. Exponential format d. Number format

A

89. You can use the ____________ formatting strings with integers to specify the minimum width for displaying the number. a. "D" or "d" b. "E" or "e" c. "F" or "f" d. "P" or "p"

A

92. In C#, an exception handler is written with the ____________ statement. a. try-catch b. catch-try c. run-break d. break-run

A

96. The ____________ property lets you designate a button on a form that will be automatically clicked when the user presses the Esc key. a. CancelButton b. ExitButton c. EscapeButton d. StopButton

A

10. In a try-catch statement, the ____________ keyword appears immediately after the try block. a. try b. catch c. break d. continue

B

15. Which one of the following statements declares a named constant named GRAVITY with an initialization value of 9.8? a. double GRAVITY = 9.8 const; b. const double GRAVITY = 9.8; c. double const GRAVITY = 9.8; d. double GRAVITY const = 9.8;

B

16. A ____________ is a variable that is declared inside a class but not inside of any method. a. named constant b. field c. namespace d. property

B

17. A(n) ____________ specifies how a class member can be accessed by code located outside the class. a. variable name b. access modifier c. namespace d. class name

B

19. A ____________ is a field whose value cannot be modified at runtime. a. literal field b. constant field c. sentinel field d. common field

B

22. The order in which controls receive the focus is called the ____________. a. focus index b. tab order c. order element d. tab index

B

24. Clicking View and then Tab Order on the Visual Studio menu bar will cause the form to be displayed in __________ mode. a. design b. tab order selection c. default focus d. compile

B

29. Which one of the following statements clears the Text property of a TextBox control named addressTextBox? a. addressTextBox.Text = Text.Clear; b. addressTextBox.Text = ""; c. addressTextBox = Nothing; d. addressTextBox.Empty();

B

3. A numeric literal that is assumed to be an integer is called a(n) ____________. a. real number b. integer literal c. natural literal d. common value

B

32. Which one of the following is the general format for a variable declaration statement? a. VariableName DataType; b. DataType VariableName; c. DataName VariableType; d. NameType VaraibleData;

B

33. Fundamental types of data, such as integers and real numbers are known as ____________. a. fundamental data types b. primitive data types c. natural data types d. basic data types

B

40. Inside a method, a variable's declaration statement must appear ____________ any other statements that use the variable. a. after b. before c. near d. in

B

41. A(n) ____________ variable belongs to the method in which it is declared, and only statements inside that method can access the variable. a. limited b. local c. global d. static

B

44. A variable's ____________ is the time period during which the variable exists in memory while the program is executing. a. span b. lifetime c. instance d. latency

B

50. Which one of the following statements initializes the color variable with the string "red"? a. color = "red"; b. string color = "red"; c. "red" = string color; d. string color("red");

B

53. A variable of the ____________ data type can hold whole numbers only. a. string b. int c. double d. decimal

B

6. Which one of the following statements initializes a variable with a double literal? a. string modelNumber = "R2C32"; b. double percentage = 23.59; c. int width = 150; d. decimal bonus = 0.99m;

B

63. The programming language's ____________ dictates which operations are performed first in a mathematical expression. a. least significant value b. order of operations c. compiler version d. operator position

B

66. When an operation is performed on two double values, the result will be a(n) ____________. a. int b. double c. string d. decimal

B

72. C# has a special set of operators known as ____________ that change the value of a variable without having to type the variable name twice. a. identity operators b. combined assignment operators c. quick-change operators d. assessment operators

B

76. The ____________ method can be used to convert a string to a double. a. Parse.double b. double.Parse c. ToString.double d. double.ToString

B

79. A(n) ____________ is an unexpected error that occurs while a program is running, causing the program to halt if the error is not properly dealt with. a. bug b. exception c. logic error d. illegal operation

B

8. Which one of the following statements initializes a variable with a decimal literal? a. string displayPrice = "$14.99"; b. decimal budget = 450m; c. int inventory = 150; d. double volume = 30.25;

B

86. ____________ ("F" or "f") displays numeric values with no thousands separator and a decimal point. a. Number format b. Fixed-Point format c. Exponential format d. Percent format

B

90. When an exception is thrown, an application stops running and Visual Studio goes into a special mode known as ____________. a. debug mode b. break mode c. exception mode d. validation mode

B

94. A(n) ____________ also known as a mnemonic, is a key pressed in combination with the Alt key to trigger a Click event. a. shortcut key b. access key c. key binding d. alt key specifier

B

95. The ____________ property lets you designate a button on a form that will be automatically clicked when the user presses the Enter key. a. ConfirmButton b. AcceptButton c. EnterButton d. DefaultButton

B

98. Controls that display text have a ____________ property that allows you to change the color of the text. a. TextColor b. ForeColor c. FontColor d. Color

B

13. Assuming an application has an exception object named ex, which one of the following statements would cause the exception's default error message to be displayed in a message box? a. MessageBox(ex.Message); b. ex.Message = MessageBox.Text; c. MessageBox.Show(ex.Message); d. MessageBox.Text = ex.Message;

C

20. The .NET Framework provides a class named ____________ containing numerous methods for performing advanced mathematical operations. a. Linq b. Trig c. Math d. Calc

C

28. Which one of the following statements assigns the value contained in the Text property of a TextBox control named ageTextBox to the Text Property of a Label control named ageLabel? a. ageLabel = ageTextBox; b. ageTextBox.Text = ageLabel.Text; c. ageLabel.Text = ageTextBox.Text; d. ageTextBox = ageLabel;

C

30. A(n) ____________ is a storage location in memory that is represented by a name. a. declaration b. sector c. variable d. instance

C

34. A variable of the ____________ data type can hold any sequence of characters, such as a person's name, address, or password. a. int b. double c. string d. decimal

C

35. Which one of the following statements declares a string variable named message? a. message string; b. string = message; c. string message; d. string + message;

C

37. A common operation performed on strings is ____________, or appending one string to the end of another string. a. extending b. combination c. concatenation d. affixing

C

43. A ____________ variable's scope begins at the variable's declaration and ends at the end of the method in which the variable is declared. a. global b. static c. local d. basic

C

54. The ____________ data type is used to store any number that might have a fractional part. a. string b. int c. double d. boolean

C

55. You cannot assign a double or a decimal value to an int variable because such an assignment could result in ____________. a. buffer overflow b. a runtime error c. a loss of data d. value sharing conflicts

C

56. Which one of the following assignment statements will cause a syntax error because of mismatching data types? a. double density = 34.12; b. double length = 0.5; c. double bonus = 24.95m; d. double depth = 1200;

C

57. Which one of the following assignment statements will cause an error because of mismatching data types? a. decimal cost = 0.99m; b. decimal retail = 100; c. decimal wholesale = 50.0; d. decimal fee = 0.01m;

C

60. A symbol used in code for performing calculations is ____________. a. variable b. control c. math operator d. expression

C

62. The values on the right and left sides of a math operator are called ____________. a. factors b. derivatives c. operands d. identities

C

67. When an operation is performed on two decimal values, the result will be a(n) ____________. a. string b. int c. decimal d. double

C

7. Appending the letter M or m to a numeric literal causes the number to be considered a ____________. a. monetary literal b. double literal c. decimal literal d. mnemonic literal

C

70. A math expression involving a double and a(n) ____________ is not allowed unless a cast operator is used to convert one of the operands. a. int b. double c. decimal d. All of these

C

81. You can call the ToString method using the following general format: a. ToString.variableName() b. ToString(variableName) c. variableName.ToString() d. To.variableName.String()

C

85. When you pass the formatting string ____________ to the ToString method, the number is displayed with comma separators and a decimal point. a. "E" or "e" b. "C" or "c" c. "N" or "n" d. "F" or "f"

C

9. The ____________ contains statements that can potentially throw an exception. a. break block b. catch block c. try block d. run block

C

91. Code that responds to exceptions when they are thrown and prevents the program from abruptly crashing is called a(n) _____________. a. catch-all b. debugger c. exception handler d. critical state handler

C

97. Most controls have a ____________ property that allows you to change the object's background color. a. Color b. FormColor c. BackColor d. ChangeColor

C

1. The ____________ is commonly used in financial applications because it can store real numbers with a large number of digits to the right of the decimal point. a. string b. int c. double d. decimal

D

100. A ____________ control is a rectangular container for other controls. a. ComboBox b. ListBox c. GroupBox d. Panel

D

14. A ____________ is a identifier for a value that cannot be modified during the program's execution. a. sentinel b. literal c. keyword d. named constant

D

18. If you do not initialize a(n) ____________ field, it begins with a special value known as null. a. int b. decimal c. double d. string

D

25. A(n) ____________ control is a rectangular area on a form that accepts keyboard input from the user. a. Label b. PictureBox c. Input d. TextBox

D

36. Assuming a string variable named city has already been declared, which one of the following statements assigns the string literal "Vienna" to the variable? a. "Vienna" = city; b. city + "Vienna"; c. city("Vienna"); d. city = "Vienna";

D

39. Assuming a string variable named movieTitle has already been declared, which one of the following statements combines the strings "The " and "Hobbit" and then assigns the resulting string to the variable? a. movieTitle("The ", "Hobbit"); b. "The " + "Hobbit" = moveTitle; c. movieTitle = "The " & "Hobbit"; d. movieTitle = "The " + "Hobbit";

D

47. A ____________ holds only one data value at any given moment in time. a. program b. data type c. method d. variable

D

5. A numeric literal such as 3.5 is considered by the compiler to be a ____________. a. real number b. floating-point value c. decimal literal d. double literal

D

73. To convert a the contents of a string to any of the numeric data types, we use a family of methods in the .NET Framework known as the ____________. a. Convert methods b. itoa methods c. ToString methods d. Parse methods

D

74. In computer science, the term ____________ typically means to analyze a string of characters for some purpose. a. compile b. decrypt c. scan d. parse

D

77. The ____________ method can be used to convert a string to a decimal. a. decimal.ToString b. Parse.decimal c. ToString.decimal d. decimal.Parse

D

82. When using the ____________ operator, if one operand is a number and the other operand is a string, the number will be implicitly converted to a string, and both operands will be concatenated. a. & b. * c. / d. +

D

87. ____________ ("E" or "e") displays numeric values in scientific notation. a. Number format b. Percent format c. Currency format d. Exponential format

D

93. In code, you move the input focus to a control by calling the ____________ method. a. Move b. Tab c. Selection d. Focus

D

99. A ____________ control is a rectangular control that appears with a thin border and an optional title in its upper-left corner. a. Panel b. ComboBox c. ListBox d. GroupBox

D


Conjuntos de estudio relacionados

COMPTIA Complete Questions Core 2

View Set

The Immune System ( Chapter 20 )

View Set

"History Alive The United States" Chapter 29 World War II 29.7-29.12

View Set

Exam 4 Histones and Nucleosomes and nucleosome assembly

View Set

Unit 1 test review-european history

View Set

Chapter 12 Moral, Legal, and Aesthetic Reasoning, Week #1, Week #2, Critical thinking Ch 6 Moore Parker, Chapter 7-Induction Fallacies, Chapter 11 Inductive Reasoning, PHL 320 Final Exam WOTD's!!!, PHL 320 Exam 1 -- ReStudy for Final!!!, PHL 320 Exam...

View Set