class intWrap {
int x;
}
public class Main {
public static void main(String[] args) {
intWrap i = new intWrap();
i.x = 10;
intWrap j = new intWrap();
j.x = 20;
swap(i, j);
System.out.println("i.x = " + i.x + ", j.x = " + j.x);
}
public static void swap(intWrap i, intWrap j) {
int temp = i.x;
i.x = j.x;
j.x = temp;
}
}
(A) ix = 20,jx = 10
(B) ix = 10,jx = 20
(C) ix = 10,jx = 10
(D) ix = 20,jx = 20答案: (A)
说明:根本不会传递对象。仅引用被传递。变量的值始终是基元或引用,而不是对象
这个问题的测验