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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Practice</strong> <strong>Exam</strong> 4: Answers 36911. Bird b3 = (Hummingbird)b2;12. Hummingbird b4 = (Hummingbird)b2;13.14. b1.fly(); b2.fly(); b3.fly(); b4.fly();15. System.out.println(s);16. } }What is the result?A. fly fly fly flyB. fly fly fly hoverC. fly fly hover hoverD. fly hover hover hoverE. hover hover hover hoverF. Compilation fails.G. An exception is thrown at runtime.Answer (for Objective 5.2): B is correct. Remember, polymorphic invocations apply only to instance methods, notstatic methods. A, C, D, E, F, and G are incorrect based on the above.9. Given two files:1. package com;2. public class Extramuros {3. public static void howdy() { System.out.print("howdy "); }4. public static final Extramuros ex = new Extramuros();5. public int instVar = 42;6. public enum avout {OROLO, JAD};7. }1. // insert code here...6. public class Theorics {7. public static void main(String[] args) {8. Extramuros.howdy();9. System.out.print(Extramuros.avout.OROLO + " ");10. howdy();11. System.out.print(ex.instVar + " ");12. } }

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

Saved successfully!

Ooh no, something went wrong!