CSE 205- MIDTERM EXAM UPDATED ACTUAL
QUESTIONS AND CORRECT ANSWERS
Question:
1. Which of the following are valid Java Identifiers? Choose all that apply.
a) i
b) 1tax
c) java_&_point
d) abc123
e) sum and difference
f) My Variable
g) sum_of_array
h) TESTVARIABLE j) 1_age k) sum&difference
Answer:
a) i
d)abc123
g)sum_of_array
h) TESTVARIABLE
Question:
2. What will be the output of this code? int x = 3; int y = 10; int a = y; y = x; x = a; System.out.print(x);
Answer:
10
Question:
3. Evaluate this logical expression: ! false || ! true
Answer:
true
Question:
4. Evaluate this expression: 1 + 1 <= 4 && 16 - 5 > 10
Answer:
False
Question:
5. Which of the following are NOT Java primitive data types? Choose all that apply.
a)boolean
b)class
c)float
d)String
e)Random
f)int
g)double
h)char i)Array j)Math
, Answer:
b) class
d) String
e)Random i)Array j)Math
Question:
6. Which of the following Java literals have the data type double? Choose all that apply.
a)123.0
b)"true"
c)'a'
d)3f
e)false
f)-3
g)123
h)1.23f i)true j)"3.0" k)-1.23 l)'\n'
Answer:
a)123.0
f)-3
g)123 k)-1.23
Question:
7. When the following expression is evaluated, the result will be what Java data type?
61 + 66
a) int
b) float
c) double
d) boolean
e) char
f) String
g) none of these
Answer:
int
Question:
8. Which of the following would be the best data type for a variable to store the average score on the final
exam? boolean char none of these float int String
Answer:
none of these
Question:
9. Write a line of Java code that will declare a double variable named title that is initialized to the value
-22.78
Answer:
double title = -22.78;
QUESTIONS AND CORRECT ANSWERS
Question:
1. Which of the following are valid Java Identifiers? Choose all that apply.
a) i
b) 1tax
c) java_&_point
d) abc123
e) sum and difference
f) My Variable
g) sum_of_array
h) TESTVARIABLE j) 1_age k) sum&difference
Answer:
a) i
d)abc123
g)sum_of_array
h) TESTVARIABLE
Question:
2. What will be the output of this code? int x = 3; int y = 10; int a = y; y = x; x = a; System.out.print(x);
Answer:
10
Question:
3. Evaluate this logical expression: ! false || ! true
Answer:
true
Question:
4. Evaluate this expression: 1 + 1 <= 4 && 16 - 5 > 10
Answer:
False
Question:
5. Which of the following are NOT Java primitive data types? Choose all that apply.
a)boolean
b)class
c)float
d)String
e)Random
f)int
g)double
h)char i)Array j)Math
, Answer:
b) class
d) String
e)Random i)Array j)Math
Question:
6. Which of the following Java literals have the data type double? Choose all that apply.
a)123.0
b)"true"
c)'a'
d)3f
e)false
f)-3
g)123
h)1.23f i)true j)"3.0" k)-1.23 l)'\n'
Answer:
a)123.0
f)-3
g)123 k)-1.23
Question:
7. When the following expression is evaluated, the result will be what Java data type?
61 + 66
a) int
b) float
c) double
d) boolean
e) char
f) String
g) none of these
Answer:
int
Question:
8. Which of the following would be the best data type for a variable to store the average score on the final
exam? boolean char none of these float int String
Answer:
none of these
Question:
9. Write a line of Java code that will declare a double variable named title that is initialized to the value
-22.78
Answer:
double title = -22.78;