Log in
Sign up for FREE
arrow_back
Library
C# Chapter 2 Review cloned 10/28/2019
By Sarah Franklin
star
star
star
star
star
Share
share
Last updated over 6 years ago
19 questions
Add this activity
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
Question 1
1.
1. A variable declaration must contain all of the following
except
a(n) ______________.
Data Type
Identifier
Assigned Value
Ending Semicolon
Question 2
2.
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.
Question 3
3.
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);
Question 4
4.
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);
Question 5
5.
Assume that you have a variable declared as int varl = 3;. What is the value of 22 % var1?
27
7
1
0
Question 6
6.
Assume that you have a variable declared as int var1 = 3;. What is the value of 22 / var1?
21
7.333
7
1
Question 7
7.
What is the value of the expression 4 + 2 * 3?
0
10
18
36
Question 8
8.
Assume that you have a variable declared as int var1 = 3;. If var2 = ++var1, what is the value of var2?
2
3
4
5
Question 9
9.
Assume that you have a variable declared as int var1 = 3;. If var2 = var1++, what is the value of var2?
2
3
4
5
Question 10
10.
A variable that can hold the two values true and false is of type ______________.
char
it
bool
double
Question 11
11.
Which of the following is not a C# comparison operator?
=>
!=
==
<
Question 12
12.
What is the value of the expression 6 >= 7?
0
1
true
false
Question 13
13.
Which of the following C# types cannot contain floating-point numbers?
float
double
decimal
int
Question 14
14.
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
Question 15
15.
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
Question 16
16.
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
Question 17
17.
Unicode is_____________________.
an object-oriented language
a subset of the C# language
a 16-bit coding scheme
another term for hexadecimal
Question 18
18.
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";
Question 19
19.
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