Given:
public class Main { int size = 7; //from w ww.j ava 2 s. c om public static void main(String[] args) { Main m1 = new Main(); Main m2 = m1; int i1 = 10; int i2 = i1; go(m2, i2); System.out.println(m1.size + " " + i1); } static void go(Main m, int i) { m.size = 8; i = 12; } }
What is the result?
B is correct.
In the go()
method, m refers to the single Main instance, but the int i is a new int variable, a detached copy of i2.