Chapter 2
11. The file named ____________ contains code associated with a form named Form1. a. Form1.cs b. MainForm.cs c. Control.cs d. Window.cs
ANS: A
16. Code containers, such as namespaces, classes, and methods, use ____________ to enclose code. a. braces ({}) b. asterisks (**) c. parentheses (()) d. brackets ([])
ANS: A
2. Which one of the following Button control names is a legal C# identifier? a. _DisplayOption5Button b. Exit!Button c. *Clear*Button* d. delete Record Button
ANS: A
3. The ____________ naming convention gets its name because the uppercase characters that appear in a name are sometimes reminiscent of a camel's humps. a. camelCase b. Pascal c. Hungarian notation d. CaMeL style
ANS: A
32. To delete a control, you can select it on a form and then press the ____________ key on the keyboard. a. Delete b. Z c. Tab d. X
ANS: A
33. A Button control has a ____________ property that holds a string to be displayed on the face of the button. a. Text b. Name c. Description d. Face
ANS: A
37. A file that contains program code is called a ____________. a. source code file b. program file c. C# file d. cs file
ANS: A
42. When a string is written into a program's code, it is called a(n) ____________. a. string literal b. typed string c. encoded string d. string constant
ANS: A
46. The Label control can be found in the ____________ group of the Toolbox. a. Common Controls b. Containers c. Data d. Components
ANS: A
52. A ____________ property can be set to one of two possible values: True or False. a. Boolean b. Binary c. Singular d. Toggle
ANS: A
56. The standard notation for referring to a control's property in code is: a. ControlName.PropertyName b. ControlName->PropertyName c. ControlName::PropertyName d. ControlName<PropertyName/>
ANS: A
59. ____________ is a feature of Visual Studio that provides automatic code completion as you write programming statements. a. IntelliSense b. AutoComplete c. Snippet d. CodeHelper
ANS: A
68. A(n) ____________ appears on one line in a program and begins with two forward slashes (//). a. line comment b. short comment c. block comment d. documentation comment
ANS: A
14. A(n) ____________ is a sequence of one or more programming statements (code) that performs some operation. a. algorithm b. method c. class d. namespace
ANS: B
17. An easy way to switch between the Designer and the code editor is to click the ____________ for the desired window. This only works if both the code file and designer file have already been opened. a. icon b. tab c. button d. bounding box
ANS: B
19. A(n) ____________ event occurs on a control when the user clicks the mouse on a control while the program is running. a. Action b. Click c. Live d. Mouse
ANS: B
22. Which one of the following statements correctly display the text "Hello" in a message box? a. Messagebox("Hello") b. MessageBox.Show("Hello"); c. msgbox(Hello); d. msgbox.show(Hello)
ANS: B
24. ____________ allow you to resize a selected object in the Visual Studio Designer by clicking and dragging the mouse when the mouse cursor becomes a two-headed arrow. a. Bounding boxes b. Sizing handles c. ToolTips d. Properties
ANS: B
29. Selecting the ____________ button in the Properties window causes the items in the window to be displayed in logical groups. a. Grouped b. Categorized c. Ordered d. Type
ANS: B
31. In the design window, you can click and drag a control to a new location when the mouse cursor is positioned inside the control and the mouse cursor becomes a ____________. a. two-headed arrow b. four-headed arrow c. hand icon d. scissor icon
ANS: B
35. Control names are also known as ____________, the same term used for variables in programs. a. tags b. identifiers c. values d. labels
ANS: B
36. To run an application in Visual Studio, press the ____________ button on the keyboard or click the Start Debugging button on the toolbar. a. Enter b. F5 c. Tab d. Shift
ANS: B
39. In C# code, ____________ are required to indicate the beginning and the end of a string. a. single quotation marks, such as (') b. double quotation marks, such as (") c. parentheses d. semicolons
ANS: B
4. When learning computer programming, it is traditional to start by learning to write a ____________ program. a. Simple b. Hello World c. Pseudocode d. K&R Style
ANS: B
43. When you have a project open in Visual Studio, the time during which you build the GUI and write the application's code is referred to as ____________. a. prototyping b. design time c. visual planning d. application progression
ANS: B
45. When you want to display text on a form but not allow the user to change the text, you use a ____________. a. String control b. Label control c. Text control d. Font control
ANS: B
48. The ____________ can be accessed from the Properties window by clicking the ellipses (...) appearing next to the Font property's value. a. Text designer b. Font dialog box c. Text editor d. Font selector
ANS: B
51. Label controls have a(n) ____________ property that affects the way they can be resized. a. Resize b. AutoSize c. SizeMode d. Redraw
ANS: B
54. In code, you use a(n) ____________ to store a value in a control's property. a. string literal b. assignment statement c. dialog box d. constant
ANS: B
57. Which of the following statements would display the number 25 in a Label control named ouputLabel? a. outputLabel.Text = 25; b. outputLabel.Text = "25"; c. outputLabel(25); d. outputLabel = "25";
ANS: B
61. Once you have created a PictureBox control, you use its ____________ property to specify the image it will display. a. Picture b. Image c. Source d. Display
ANS: B
62. ____________ is the default value of the PictureBox control's SizeMode property. a. AutoSize b. Normal c. Zoom d. StretchImage
ANS: B
64. When a PictureBox control's SizeMode property is set to ____________, the image is uniformly resized to fit the PictureBox without losing its original aspect ratio. a. Normal b. Zoom c. CenterImage d. StretchImage
ANS: B
66. Assuming an application has a PictureBox control named profilePictureBox, which one of the following assignment statements will hide the PictureBox from the user at run time? a. profilePictureBox.Visible = False; b. profilePictureBox.Visible = false; c. profilePictureBox.Invisible = True; d. profilePictureBox.Invisible = true;
ANS: B
69. A(n) ____________ can occupy multiple consecutive lines in a program. It starts with /* (a forward slash followed by an asterisk), and ends with */ (an asterisk followed by a forward slash). a. line comment b. block comment c. short comment d. documentation comment
ANS: B
7. To close an application's form in code, you use the statement ____________. a. me.Quit(); b. this.Close(); c. form.Exit(); d. app.Stop();
ANS: B
8. When you enter a statement into the code editor, Visual Studio analyzes it, and if a syntax error is found, it is ____________. a. automatically corrected b. underlined with a jagged line c. crossed out d. highlighted
ANS: B
10. The ____________ file contains an application's start-up code, which executes when the application runs. a. Main.cs b. Code.cs c. Program.cs d. Source.cs
ANS: C
12. A ____________ is a declared block in a program between braces {...} that holds classes. a. method b. program c. namespace d. list
ANS: C
18. A(n) ____________ is a method that executes when a specific event (such as clicking the mouse) takes place while an application is running. a. action sequencer b. feature coordinator c. event handler d. incident manager
ANS: C
23. When a(n) ____________ appears around an object in the Visual Studio Designer, it indicates that the object is selected and is ready for editing. a. sizing handle b. editing icon c. bounding box d. frame
ANS: C
27. The ____________ property can be used to change a form's width and height, measured in pixels. a. Area b. Resolution c. Size d. Rectangle
ANS: C
30. The Visual Studio ____________ window shows a scrollable list of controls that you can add to a form. a. Collection b. Bank c. Toolbox d. Shelf
ANS: C
40. Just as a period marks the end of a sentence, a ____________ marks the end of a programming statement in C#. a. space b. underscore c. semicolon d. period
ANS: C
44. The time during which an application is executing is referred to as ____________. a. up time b. execution c. run time d. instancing
ANS: C
47. The ____________ property allows you to set the font, font style, and size of a control's text. a. Appearance b. Text c. Font d. Graphics
ANS: C
5. The PictureBox control's ____________ property determines whether the image stored in the control will cause the control to be shrunk or expanded. a. DisplayMode b. Visible c. SizeMode d. Render
ANS: C
53. A Label control's ____________ property can be used to change the alignment of text within the Label. a. TextPosition b. DisplayFont c. TextAlign d. HorizontalAlign
ANS: C
55. In C#, the equal sign (=) is known as the ____________. a. equality operator b. parity operator c. assignment operator d. transfer operator
ANS: C
6. Programmers commonly use ____________ in their code to create a sense of visual organization. a. different font colors b. documentation comments c. blank lines and indentation d. bold images, such as photos
ANS: C
63. ____________ is a term that refers to an image's width to height ratio. a. Area b. Bounding box c. Aspect ratio d. UV map
ANS: C
67. ____________ are short notes placed in a program's source code, explaining how the program works. a. Sketches b. Tags c. Comments d. Labels
ANS: C
70. ____________ are used by professional programmers to embed extensive documentation in a program' source code. a. Line comments b. Block comments c. Documentation comments d. Embedded comments
ANS: C
9. The ____________ shows a description of the error, the name of the source code file containing the error, the error's line number and column number, and the name of the project. a. Debug dialog box b. Crash pop up c. Error List window d. Just In Time debugger
ANS: C
1. Which one of the following Button control names is not a legal C# identifier? a. _calculateTotalButton b. printSalesReportButton c. clear_customer_names_button d. 1stPlayerStartButton
ANS: D
13. A(n) ____________ is a logical container in a program that holds methods (as well as other program elements). a. event b. namespace c. queue d. class
ANS: D
15. The ____________ directives appearing at the top of a C# source code file indicate which namespaces the program will use. Usually, these namespaces belong to the .NET Framework. a. include b. namespace c. public d. using
ANS: D
20. A ____________ is a small pop-up window, also known as a dialog box, that displays a message. a. standard window b. pop up c. banner d. message box
ANS: D
21. If you want your code to execute a method, write a statement known as a(n) ____________. a. event handler b. executor statement c. initialization routine d. method call
ANS: D
25. When you select an object in the Visual Studio Designer, the object's size, color, text, and other characteristics are displayed in the ____________ window. a. Designer b. Editing c. Object d. Properties
ANS: D
26. The ____________ property of a form determines the text that is displayed in a form's title bar. a. Title b. Caption c. Name d. Text
ANS: D
28. When selected in the Properties window toolbar, the ____________ button causes the items in the Properties window to be displayed in alphabetical order. a. Arrange b. Ascending c. Descending d. Alphabetical
ANS: D
34. A control's ____________ property identifies the control in the application's code and in the Visual Studio environment. a. Text b. Source c. Tag d. Name
ANS: D
38. In programming we use the term ____________ to mean a sequence of characters that could be enclosed in quotation marks "...". a. statement b. thread c. word d. string
ANS: D
41. When a piece of data such as 23 or "Hello" is written into a program's code, it is called a ____________. a. constant b. sentinel c. value d. literal
ANS: D
49. Each Label control has a ____________ property that allows you to display a rectangle around the control's text. a. Border b. FrameStyle c. Frame d. BorderStyle
ANS: D
50. Which one of the following is not a valid setting for a Label control's BorderStyle property? a. FixedSingle b. None c. Fixed3D d. FixedDouble
ANS: D
58. Which of the following statements would clear the text displayed in a Label control named cityLabel? a. cityLabel.Text = "empty"; b. cityLabel.Text = "none"; c. cityLabel.Text = "clear"; d. cityLabel.Text = "";
ANS: D
60. You can use a(n) ____________ control to display a graphic image on a form. a. Image b. Graphics c. Texture2D d. PictureBox
ANS: D
65. Most controls have a(n) ____________ property that determines whether the control can be seen by the user at run time. a. Enabled b. Invisible c. Show d. Visible
ANS: D
11. The standard Windows close button is the only way to close a running application in Visual Studio.
ANS: F
16. Changing a form's Text property will change the form's name.
ANS: F
17. When the properties in the Properties window are displayed alphabetically, the (name) property appears at the bottom of the list.
ANS: F
19. You cannot click and drag controls from the Toolbox onto a form.
ANS: F
2. A control's Visible property cannot be modified in code.
ANS: F
20. Once a control has been added to a form, it cannot be deleted.
ANS: F
21. To remove a control from a form, you select it and then press the F4 key on the keyboard.
ANS: F
26. C# identifiers can contain spaces after the first character.
ANS: F
29. The only way to run a program in Visual Studio is by clicking the Start Debugging button on the toolbar.
ANS: F
31. The Program.cs file contains auto-generated code that serves as an outline to which you should add your own code as you develop the application.
ANS: F
32. It is important that you do not modify the contents of the Form1.cs file because doing so will prevent the application from executing.
ANS: F
34. C# code is organized using namespaces, which are contained inside classes, which are contained inside methods.
ANS: F
40. Single quotation marks can be used in program code to mark the beginning and ending of a string.
ANS: F
41. Ending a programming statement with a semicolon is not required in C#.
ANS: F
42. If you wish to create a Click event handler for a control in Visual Studio, it is not necessary to double-click the control in the Designer first.
ANS: F
44. Programmers sometimes say that literals are values that are soft coded into a program because the value of a literal can be changed while the program is running.
ANS: F
45. In a C# application, all buttons on a form must share the same Click event handler in form's source code file.
ANS: F
46. At run time, you should not use the Designer, Toolbox, Properties window, or code editor to modify the program.
ANS: F
5. Comments are short notes intended for the compiler to read and interpret.
ANS: F
50. A control's name should never be changed to something other than the default name that Visual Studio gives it.
ANS: F
51. A Label control's BorderStyle property is set to FixedSingle by default.
ANS: F
54. The assignment operator assigns the value that appears on its left side to the item that appears on its right side.
ANS: F
55. Because the Label control's Text property can accept only strings, you cannot display a number in a label.
ANS: F
6. In C#, there are three types of comments: line comments, block comments, and compilation comments.
ANS: F
60. PictureBox controls have a BorderStyle property, but it does not work like a Label control's BorderStyle property.
ANS: F
61. Buttons are the only controls that respond to Click events.
ANS: F
9. Writing comments should be avoided, especially for large and complex programs.
ANS: F
True or False 1. When you use the Properties window to change a control's Visible property at design time, the control will become invisible in the Designer.
ANS: F
10. The indentation of statements inside methods, classes, and namespaces is a convention that virtually all programmers follow.
ANS: T
12. If you double-click an error message in the Error List window, the code editor will highlight and display the line of code that caused the error.
ANS: T
13. Each form and control in an application's GUI is assigned a default name.
ANS: T
14. The appearance and other characteristics of a GUI object are determined by the object's properties.
ANS: T
15. The Properties window contains a scrollable list of properties, which has two columns: the left column shows each property's name, and the right column shows each property's value.
ANS: T
18. To add a control to a form, you find it in the Toolbox and then double-click it.
ANS: T
22. When you create Button controls, they are automatically given default names such as button1, button2, and so forth.
ANS: T
23. When Button control is created, its Text property is initially set to the same value as the Button control's name.
ANS: T
24. Text displayed on a button should hint at what the button will do when it is clicked.
ANS: T
25. A control's name should reflect the purpose of the control.
ANS: T
27. The first character of a C# identifier must be one of the letters a through z or A through Z or an underscore character (_).
ANS: T
28. A Hello World program is a simple program that merely displays the words "Hello World" on the screen.
ANS: T
3. When you write the values true or false in code, they must be written in all lowercase letters.
ANS: T
30. C# source code files always end with the .cs extension.
ANS: T
33. C# code is primarily organized in three ways: namespaces, classes, and methods.
ANS: T
35. Each opening brace ({) of a code container must have a matching closing brace (}) later in the program.
ANS: T
36. You can detach the code editor window and use the mouse to drag it to another part of the screen.
ANS: T
37. When an event handler is generated for a control by Visual Studio, it doesn't do anything until you add your own code.
ANS: T
38. The .NET Framework provides a method named MessageBox.Show that you can use in Visual C# to display a pop-up message box.
ANS: T
39. Programmers refer to the act of executing a method as calling the method.
ANS: T
4. When a method executes, the statements in the method always execute in the order that they appear, from the beginning of the method to the end of the method.
ANS: T
43. In C#, string literals must be enclosed in double quotation marks.
ANS: T
47. The terms run time, runtime, and run-time all typically mean the same thing.
ANS: T
48. Once you have placed a Label control on a form, set its Text property to the string you want to display.
ANS: T
49. A Label control's Text property is initially set to the same value as the Label control's name.
ANS: T
52. To change the BorderStyle property of a Label control in the Designer, select it in the Properties window and then click the down-arrow button that appears next to the value.
ANS: T
53. By default, a Label control's text is aligned with the top and left edges of the label's bounding box.
ANS: T
56. In code, if you want to clear the text that is displayed in a Label control, you can assign an empty string ("") to the control's Text property.
ANS: T
57. When typing a statement in code, press the Tab key on the keyboard to accept suggestions made by the IntelliSense feature of Visual Studio.
ANS: T
58. In the Designer, the PictureBox tool is located in the Common Controls group in the Toolbox window.
ANS: T
59. When the PictureBox control's SizeMode property is set to AutoSize, the PictureBox control is automatically resized to fit the size of the image being displayed.
ANS: T
7. A line comment does not have to occupy an entire line, so a line comment can appear after an executable statement.
ANS: T
8. Block comments make it easier to write long explanations because you do not have to mark every line with a comment symbol.
ANS: T