Q1. Given the code fragment:
How many times is 2 printed?
A. Zero
B. Once
C. Twice
D. Thrice
E. It is not printed because compilation fails
Answer: B
Q2. Given:
How many objects have been created when the line / / do complex stuff is reached?
A. Two
B. Three
C. Four
D. Six
Answer: C
Q3. Given:
What is the result?
A. 10 : 22 : 20
B. 10 : 22 : 22
C. 10 : 22 : 6
D. 10 : 30 : 6
Answer: B
Q4. Given:
What is the result?
A. 0
B. 0 1 2
C. 0 1 2 0 1 2 0 1 2
D. Compilation fails
Answer: B
Q5. Given:
What is the result?
A. Marrown
String out of limits
JesOran
B. Marrown
String out of limits
Array out of limits
C. Marrown
String out of limits
D. Marrown
NanRed
JesOran
Answer: D
Q6. What is the proper way to defined a method that take two int values and returns their sum as an int value?
A. int sum(int first, int second) { first + second; }
B. int sum(int first, second) { return first + second; }
C. sum(int first, int second) { return first + second; }
D. int sum(int first, int second) { return first + second; }
E. void sum (int first, int second) { return first + second; }
Answer: D
Q7. Given:
What is the result?
A. 1 1 1
B. 1 2 3
C. 2 3 4
D. Compilation fails
E. The loop executes infinite times
Answer: D
Q8. What is the result if the integer aVar is 9?
A. 10 Hello world!
B. 10 Hello universe!
C. 9 Hello world!
D. Compilation fails.
Answer: C
Q9. Given:
What is the result?
A. Compilation fails
B. An exception is thrown at runtime
C. There is no result because this is not correct way to determine the hash code
D. Hash is: 111111, 44444444, 999999999
Answer: A
Q10. What is the result?
A. sc: class.Object asc: class.AnotherSampleClass
B. sc: class.SampleClass asc: class.AnotherSampleClass
C. sc: class.AnotherSampleClass asc: class.SampleClass
D. sc: class.AnotherSampleClass asc: class.AnotherSampleClass
Answer: D