Use LEFT and RIGHT arrow keys to navigate between flashcards;
Use UP and DOWN arrow keys to flip the card;
H to show hint;
A reads text to speech;
59 Cards in this Set
- Front
- Back
What control can be used to gather text input from the user? |
A TextBox control |
|
In code, how do you retrieve data that has been typed into a TextBox control? |
Retrieve the contents of the control’s Text property |
|
What type of data does a control’s Text property always contain? |
A string |
|
How do you clear the contents of a TextBox control? |
Assign an empty string ( "" ) to the Text property. |
|
What is the purpose of a variable? |
To store a value in memory |
|
Give an example of a variable declaration that will store the name of your favorite |
string myFavoriteFood = "pizza"; |
|
For each of the following items, determine whether the data type should be an |
a. String |
|
Indicate whether each of the following is a legal variable name. If it is not, explain |
a. Legal |
|
What will be stored in the message variable after the following statement is |
The string "Hello!" |
|
What is the lifetime of a variable that is declared inside of a Click event handler? |
While the event is executing; then it is deleted. |
|
Assuming the variable greeting has not been assigned a value, what will be the |
The statement will result in an error. |
|
Will the following statement cause an error? Why or why not? |
Yes, string variables can be assigned only string values. |
|
Write a single declaration statement for the variables name , city , and state . |
string name, city, state; |
|
Specify the appropriate primitive numeric data type to use for each of the following |
a. decimal |
|
Which of the following variable declarations will cause an error? Why? |
b, variables of the int data type can be assigned only whole-number values. |
|
Write a programming statement that will convert the following decimal variable |
int dollars = (int)deposit; |
|
What value will the wholePieces variable contain after the following code |
6 |
|
List the operands for the following math expression. |
length and width |
|
Summarize the mathematical order of operations. |
1. Perform any operations that are enclosed in parentheses. |
|
Rewrite the following code segment so that it does not cause an error. |
decimal pricePerFoot = 2.99m; |
|
Assume result is a double variable. When the following statement executes, |
9 |
|
Assume result is an int variable. When the following statement executes, what |
70 |
|
Assume result is a double variable. When the following statement executes, |
2.5 |
|
Rewrite the following statements using combined assignment operators: |
a. count += 1; |
|
What method converts the string literal "40" to a value of the int data type? |
int.Parse |
|
Write a statement that converts each of the following string values to the decimal |
a. decimal.Parse("90.5"); |
|
Suppose an application has a decimal variable named total and a Label control |
The result will be an error because numeric values cannot be assigned to |
|
Write a statement that displays each of the following numeric variables in a |
a. MessageBox.Show(grandTotal.ToString()); |
|
Write a statement that will store the value of an int variable named result in the |
resultLabel.Text = result.ToString(); |
|
Write a programming statement that displays the string value of a variable named |
MessageBox.Show(salary.ToString("c")); |
|
The following variable names give an indication of the data each stores. For each |
a. "P" or "p" for percent format |
|
What value will be displayed in the message box when the following code segment |
12 |
|
Examine the following integer variables and specify the number of leading zeros to |
"d5" |
|
Write a programming statement that uses the ToString method of a variable |
millimeters.ToString("f4"); |
|
What can cause an application to throw an exception? |
An unexpected error that occurs while a program is running, such as user input |
|
How do you get out of break mode when an exception is thrown? |
Click the Stop Debugging button or by pressing shift+F5 |
|
What kind of code does the try block of a try - catch statement contain? |
Statements that can potentially throw an exception |
|
What causes the program to jump to the catch clause and execute the catch block |
If a statement in the try block throws an exception |
|
How can you display the default error message when an exception is thrown? |
Assign a name to the exception object when writing the catch clause of |
|
Write a try - catch statement for an application that calculates the sum of two |
try |
|
What are two advantages of using named constants? |
They make programs more self-explanatory and allow for widespread changes to |
|
Write a programming statement that declares a named constant for a 10 percent |
const double DISCOUNT = 0.9; |
|
Where should you place field declarations in a program? |
At the top of a class declaration, before any methods |
|
What access modifier should you use when declaring a field? Why? |
It’s a good programming practice to make fields private because private fields |
|
How is the lifetime of a field different from the lifetime of a local variable? |
A local variable exists only while the method in which it is declared is executing, |
|
Write a programming statement that declares a constant field for a 5.9 percent |
private const decimal INTEREST_RATE = 0.059m; |
|
Write a programming statement that uses the Math.Pow method to square the |
double product = Math.Pow(12.0, 2.0); |
|
What method of the Math class can be used to determine the larger of two |
Math.Max |
|
What method of the Math class can be used to determine the smaller of two |
Math.Min |
|
What happens if you press the Enter key while a Button control has the focus? |
The button’s Click event handler will execute. |
|
How do you display a form in tab order selection mode? How do you exit tab |
Click View on the Visual Studio menu bar and then click Tab Order . Exit tab |
|
Write a programming statement that gives the focus to a TextBox control named |
numberTextBox.Focus(); |
|
How do you assign an access key to a Button control? |
In the Text property, place an ampersand (&) before the character you wish to |
|
How do you display an ampersand (&) character on a Button control? |
In the Text property, place two ampersand (&&) characters where you would |
|
Write the code that will change the BackColor property of a Label control named |
resultLabel.BackColor = Color.White; |
|
List the different values of a form’s BackgroundImageLayout property. |
None, Tile, Center, Stretch, and Zoom |
|
When a GroupBox control is deleted, what happens to the controls that are inside? |
The controls inside the GroupBox control are also deleted. |
|
How are the TabIndex properties of the controls inside the group box organized? |
The TabIndex values of controls inside a group box are organized relative to the |
|
How is a Panel control different from a GroupBox control? |
A Panel cannot display a title and does not have a Text property. A Panel’s |