Q1. Class StaticField {
static int i = 7;
public static void main(String[] args) {
StaticFied obj = new StaticField();
obj.i++;
StaticField.i++;
obj.i++;
System.out.println(StaticField.i + " "+ obj.i);
}
}
What is the result?
A. 10 10
B. 8 9
C. 9 8
D. 7 10
Answer: A
Q2. Given the code fragment:
What is the result?
A. 2 2
B. 1 2
C. 3 2
D. 3 3
Answer: A
Q3. which three lines are illegal?
A. line 3
B. line 4
C. line 5
D. line 6
E. line 10
F. line 11
G. line 12
H. line 13
Answer: CDH
Q4. Given the code format:
Which code fragment must be inserted at line 6 to enable the code to compile?
A. DBConfiguration f; return f;
B. Return DBConfiguration;
C. Return new DBConfiguration;
D. Retutn 0;
Answer: B
Q5. Given the code fragment:
What is the result?
A. 10 8 6 4 2 0
B. 10 8 6 4 2
C. An Arithmetic Exception is thrown at runtime
D. The program goes into an infinite loop outputting: 10 8 6 4 2 0. . .
E. Compilation fails
Answer: B
Q6. Given the code fragment:
What is the result?
A. 28false29 true
B. 285 < 429 true
C. true true
D. compilation fails
Answer: C
Q7. 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
Q8. A method is declared to take three arguments. A program calls this method and passes only two arguments. What is the result?
A. Compilation fails.
B. The third argument is given the value null.
C. The third argument is given the value void.
D. The third argument is given the value zero.
E. The third argument is given the appropriate false value for its declared type.
F. An exception occurs when the method attempts to access the third argument.
Answer: A
Q9. 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
Q10. Given:
What is the result?
A. The program prints nothing
B. d
C. A S StringIndexOutOfBoundsException is thrown at runtime.
D. AnArrayIndexOutOfBoundsException is thrown at runtime.
E. A NullPointerException is thrown at runtime.
Answer: C
Q11. 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
Q12. Given:
Which two classes use the shape class correctly?
A. Option A
B. Option B
C. Option C
D. Option D
E. Option E
F. Option F
Answer: BE
Q13. 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
Q14. Given the code fragment:
What is the result?
A. Found Red
B. Found Red
Found Blue
C. Found Red
Found Blue
Found White
D. Found Red
Found Blue
Found White
Found Default
Answer: B
Q15. Given:
What is the result?
Oracle 1z0-803 : Practice Test
A. 0 Done
B. First Exception Done
C. Second Exception
D. Done Third Exception
E. Third Exception
Answer: B
Q16. Which code fragment, when inserted at line 9, enables the code to print true?
A. String str2 = str1;
B. String str2 = new string (str1);
C. String str2 = sb1.toString();
D. String str2 = “Duke”;
Answer: B