nerdexam
Oracle

1Z0-850 · Question #28

1Z0-850 Question #28: Real Exam Question with Answer & Explanation

Sign in or unlock 1Z0-850 to reveal the answer and full explanation for question #28. The question stem and answer options stay visible for context.

Question

Given:
  1. public class Foo {
  2. int size;
  3. public static void main(String[] args) {
  4. Foo f = new Foo();
  5. f.setSize(5);
  6. Foo g = f.go(f);
  7. System.out.print(f.size + " : " + g.size);
  8. }
  9. void setSize(int s) {
  10. size = s;
  11. }
  12. public Foo go(Foo g) {
  13. g.setSize(2);
  14. return g;
  15. }
  16. } What is the result?

Options

  • ACompilation fails.
  • B5 : 5
  • C5 : 2
  • D2 : 2

Unlock 1Z0-850 to see the answer

You've previewed enough free 1Z0-850 questions. Unlock 1Z0-850 for full answers, explanations, the timed quiz mode, progress tracking, and the master PDF. Question stem and options stay visible so you can still see what's on the exam.

Full 1Z0-850 Practice