Question:What will be the output when this code is compiled and run?
public class Test { public Test() { Bar b = new Bar(); Bar b1 = new Bar(); update(b); update(b1); b1 = b; update(b); update(b1); } private void update(Bar bar) { bar.x = 20; System.out.println(bar.x); } public static void main(String args[]) { new Test(); } private class Bar { int x = 10; } }
A The code will fail to compile.
B 10 10 10 10
C 20 20 20 20
D 10 20 10 20
+ AnswerC
+ Report