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.

314Chapter 6: <strong>Practice</strong> <strong>Exam</strong> 3When the code reaches line 6, which are eligible for garbage collection? (Choose all that apply.)A. stB. inC. i3D. The object created on line 5.E. The object created on line 9.F. The object created on line 10.G. The object created on line 11.Answer (for Objective 7.4): D, E, and F are correct. A, B, and C are incorrect because only objects are considered by the GC. G is incorrectbecause main() could still access line 11’s Toolbox object through st.55. Given:2. class Ball {3. static String s = "";4. void doStuff() { s += "bounce "; }5. }6. class Basketball extends Ball {7. void doStuff() { s += "swish "; }8. }9. public class Golfball extends Ball {10. public static void main(String[] args) {11. Ball b = new Golfball();12. Basketball bb = (Basketball)b;13. b.doStuff();14. bb.doStuff();15. System.out.println(s);16. }17. void doStuff() { s += "fore "; }18. }What is the result?A. fore foreB. fore swishC. bounce swish

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

Saved successfully!

Ooh no, something went wrong!