13.07.2015 Views

OCP Java SE 6 Programmer Practice Exams (Exam 310 ... - Kitabxana

OCP Java SE 6 Programmer Practice Exams (Exam 310 ... - Kitabxana

OCP Java SE 6 Programmer Practice Exams (Exam 310 ... - Kitabxana

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Assessment Test 2: Answers 43Which are true? (Choose all that apply.)A. Compilation fails.B. The output will include "+"C. The output will include "10001"D. The output will include "0000010001"E. The output will include today’s date.F. The output will include the number of milliseconds from January 1, 1970 until today.Answer (for Objective 7.1): A is correct. Both Short and Long have static MAX_VALUE fields, so the reference to MAX_VALUE in line 9 is ambiguous. (If line 4 was removed, the answer would be B, C, D, and E.) B, C, D, E, and F are incorrect based on the above.4. Given:1. public class WeatherTest {2. static Weather w;3. public static void main(String[] args) {4. System.out.print(w.RAINY.count + " " + w.Sunny.count + " ");5. }6. }7. enum Weather {8. RAINY, Sunny;9. int count = 0;10. Weather() {11. System.out.print("c ");12. count++;13. }14. }What is the result?A. c 1 c 1B. c 1 c 2C. c c 1 1D. c c 1 2E. c c 2 2F. Compilation fails.G. An exception is thrown at runtime.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!