Log in
Sign up for FREE
arrow_back
Library

C# Chapter 2 Review cloned 10/28/2019

star
star
star
star
star
Last updated over 6 years ago
19 questions
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
Question 1
1.

Question 2
2.

Question 3
3.

Question 4
4.

Question 5
5.

Question 6
6.

Question 7
7.

Question 8
8.

Question 9
9.

Question 10
10.

Question 11
11.

Question 12
12.

Question 13
13.

Question 14
14.

Question 15
15.

Question 16
16.

Question 17
17.

Question 18
18.

Question 19
19.

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