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:
- public class Foo {
- int size;
- public static void main(String[] args) {
- Foo f = new Foo();
- f.setSize(5);
- Foo g = f.go(f);
- System.out.print(f.size + " : " + g.size);
- }
- void setSize(int s) {
- size = s;
- }
- public Foo go(Foo g) {
- g.setSize(2);
- return g;
- }
- } 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.