C# Ch2
1. Which of the following compares two string variables named string1 and string2 to determine if their contents are equal? a. stringl = string2 b. stringl == string2 c. Equals.String(string1, string2) d. two of the above
tringl == string2
1. Assume that you have a variable declared as int var1 = 3;. If var2 = var1++, what is the value of var2? a. 2 b. 3 c. 4 d. 5
3
1. Assume that you have a variable declared as int var1 = 3;. If var2 = ++var1, what is the value of var2? a. 2 b. 3 c. 4 d. 5
4
1. What is the value of the expression 6 >= 7? a. 0 b. 1 c. true d. false
false
1. Assume that you have a variable declared as int var1 = 3;. What is the value of 22 / var1? a. 21 b. 7.333 c. 7 d. 1
7
1. Which of the following is not a C# comparison operator? a. => b. != c. == d. <
=>
1. Assume that you have declared a variable as double hourly = 13.00;. What will the statement WriteLine(hourly); display? a. 13 b. 13.0 c. 13.00 d. 13.000000
13
1. Assume that you have a variable declared as int varl = 3;. What is the value of 22 % var1? a. 21 b. 7 c. 1 d. 0
1
1. What is the value of the expression 4 + 2 * 3? a. 0 b. 10 c. 18 d. 36
10
1. Which of the following is true of variable declarations? a. Two variables of different types can be declared in the same statement. b. Two variables of the same type can be declared in the same statement. c. Two variables of the same type must be declared in the same statement. d. Two variables of the same type cannot coexist in a program.
Two variables of the same type can be declared in the same statement.
1. When you perform arithmetic operations with operands of different types, such as adding an int and a float____________________ . a. C# chooses a unifying type for the result b. you must choose a unifying type for the result c. you must provide a cast d. you receive an error message
a. C# chooses a unifying type for the result
1. Assume that you have a variable declared as int var1 = 3;. Which of the following would display X 3X? a. WriteLine("X{0}X", var1); b. WriteLine("X{0,2}X", varl); c. WriteLine("X{2,0}X", varl); d. WriteLine("X{0}{2}", varl);
WriteLine("X{0,2}X", varl);
1. Assume that you have two variables declared as int var1 = 3; and int var2 = 8;. Which of the following would display 838? a. WriteLine("{0}{1}{2}", var1, var2); b. WriteLine("{0}{1}{0}", var2, var1); c. WriteLine("{0}{1}{2}", var2, var1); d. WriteLine("{0}{1}{0}", var1, var2);
WriteLine("{0}{1}{0}", var2, var1);
1. Assume that you have declared a variable as double salary = 45000.00;. Which of the following will display $45,000? a. WriteLine(salary.ToString("c")); b. WriteLine(salary.ToString("c0")); c. WriteLine(salary); d. two of these
WriteLine(salary.ToString("c0"));
1. Unicode is_____________________. a. an object-oriented language b. a subset of the C# language c. a 16-bit coding scheme d. another term for hexadecimal
a 16-bit coding scheme
1. A variable declaration must contain all of the following except a(n) ______________. a. data type b. identifier c. assigned value d. ending semicolon
assigned value
1. A variable that can hold the two values true and false is of type ______________. a. char b. it c. bool d. double
bool
1. Which of the following C# types cannot contain floating-point numbers? a. float b. double c. decimal d. int
int
1. When you use a number such as 45 in a C# program, the number is a ______________. a. figurative constant b. literal constant c. literal variable d. figurative variable
literal constant
1. Which of the following declares a variable that can hold the word computer? a. string device = 'computer'; b. string device = "computer"; c. char device = 'computer';
string device = "computer";