1 Which of the following is a valid identifier?
A. namespace
B. variable 1
C. exampleOfAValue
D. 3value
E. value#1
2 The number 768 is an example of a ________type.
A. bool
B. integer
C. floating-point
D. struct
E. decimal
3 Which of the following is a reference type?
A. int
B. bool
C. string
D. decimal
E. integer
4 The character that cannot be used with an identifier is:
A. .
B. $
C. *
D. #
E. all of the above
5 Which of the following is a reserved keyword?
A. Console
B. data
C. int
D. System
E. all of the above
6 One of primary differences between float, double, and decimal is:
A. float is used to represent more significant digits.
B. double is normally used with large monetary values.
C. decimal is not used to display negative values.
D. double does not require suffixing a numeric literal with a value such as m or f.
E. decimal is primarily used to represent small monetary values that require a $ for formatting.
7 Which of the following is a valid declaration for a variable to store the name of this textbook?
A. string name of book;
B. char nameOfBook;
C. boolean nameOfBook;
D. string bookName;
E. char book Name;
8 Types are implemented in C# using:
A. classes
B. types
C. objects
D. names
E. programs
9 An object of the int class is:
A. 47.98
B. 47
C. int class
D. type object
E. type interger
10 What would be an appropriate declaration for a variable to indicate whether a value has reached its upper limit?
A. int upperLimit;
B. upperLimit reached;
C. bool upperLimit;
D. Boolean upperLimit;
E. string upperLimit;
11 Adding the keyword const to a declaration:
A. places a value in memory that cannot be changed
B. declares variables of the constant type
C. must be done by placing it after the identifier in the declaration
D. can only be done with the integral types
E. is prohibited in C#
12 Which statement increases the result by 15?
A. 15 + = result;
B. 15 =+ result;
C. result =+ 15;
D. result += 15;
E. result = 15 +;
13 What is stored in the variable ans as a result of the arithmetic expression, given the following declarations?
int ans = 0, vl = 10, v2 = 19;
ans = --v2 % vl++;
A. 1.8
B. 9
C. 8
D. 2
E. none of the above
14 What is stored in variable ans as a result of the arithmetic expression, given the following declarations?
int ans = 10
int vi = 5;
int v2 = 7;
int v3 = 18;
ans += vi + 10 * (v2-- / 5) + v3 / v2;
A. 18
B. 32
C. 28
D. 30
E. none of the above
15 Which of the following formats the number 86 to display with two digits to the right of the decimal?
A. {O:C}
B. {O:c}
C. {0:f2}
D. all of the above
E. none of the above
16 Check mark the expressions that are valid identifiers?
If they are invalid, indicate why.
A. intValue
B. value#l
C. the first value
D. _value1
E. AVALUE
17 For each of the following, code a variable decalaration using the best choice for data type
A. a counter for the number of correct responses
B the amount of money you owe on a credit card
C the name of your hometown
D the grade you hope to obtain on the next exam
E the letter grade you hope is recorded at the end of the term for this course
18 For each of the variable declarations in problem 18, add an appropriate compile-time initialization.
A. counter for the number of correct responses begins with zero
B amount of money you owe on a credit card is zero
C name of the hometown or the city where your school is located
D grade on the next exam is 100
E grade to be recorded at the end of the term for this course is an A
19 int x = 2;
int y = 6;
int z = 10;
What will be value of each of these variables after each of the following statements is executed? (For each exercise, use the original declaration..
x y z
A. z += ++y % 2;
B. x = y + 14 - z / 7;
C. x = y * z / 2 - x * z;
D. x %= --z - y * 2;
E. y = (z - y) * 2 + --y;
20 double x = 2.5;
double y = 6.9;
double z = 10.0;
What will be value of each of these variables after each of the following statements is executed? (For each exercise, use the original declaration.
x y z
A. z *= y++ % 7;
B. x = (int) y + (14 - z /7);
C. x = z / 3 * --y;
D. z /= (int) y / x;
E. z = x + Y / 4;
21 What will be the output from each of the following statements?
A. Console.Write("Result is {O:c}", 67);
B. Console.Write("Number {O:fO} is {1:c}", 1,3);
C. Console.Write("{O:fO}- {1:c}", 1,3 * 2);
D. Console.Write(" {O:fO} result" + "xyz {1:f2}", 1,25);
E. Console.Write("This is the {O:fO}st example: {1:f2}", 1,3);
22 Explain how a variable differs from a constant.
23 Explain how type, class, and object are related to a string.