Q1. 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
Q2. Given:
What is the result?
A. One
B. Two
C. Three
D. Compilation fails
Answer: C
Q3. Given:
What code should be inserted?
A. Option A
B. Option B
C. Option C
D. Option D
E. Option E
F. Option F
Answer: C
Q4. Which two may precede the word ‘class’ in a class declaration?
A. local
B. public
C. static
D. volatile
E. synchronized
Answer: BC
Q5. What is the result?
A. 3 false 1
B. 2 true 3
C. 2 false 3
D. 3 true 1
E. 3 false 3
F. 2 true 1
G. 2 false 1
Answer: D
Q6. Given the code fragment:
System.out.printIn ("Result: " +3+5);
System.out.printIn ("Result: " + (3+5));
What is the result?
A. Result: 8
Result: 8
B. Result: 35
Result: 8
C. Result: 8
Result: 35
D. Result: 35
Result: 35
Answer: B
Q7. Given:
What is the result?
A. true true
B. true false
C. false true
D. false false
E. Compilation fails
Answer: E
Q8. What is the result when this program is executed?
A. Bob's Name: Bob
B. Bob's Name: Jian
C. Nothing prints
D. Bob’s name
Answer: B
Q9. Given the code fragment:
What is the result?
A. 2 2
B. 1 2
C. 3 2
D. 3 3
Answer: A
Q10. You are writing a method that is declared not to return a value. Which two are permitted in
the method body?
A. omission of the return statement
B. return null;
C. return void;
D. return;
Answer: AD