河南成教 / Java程序设计
[简答题] 阅读下列程序,请写出该程序的输出结果。
class A {
int x, y;
A(int a, int b) {
x= a; y= b;
}
}
public class sample {
public static void main(String args[]) {
A pl, p2;
p2 = new A(12, 15);
p1 = p2; p2.x++;
System.out.println("p1.x=" + p1 .x);
}
}
class A {
int x, y;
A(int a, int b) {
x= a; y= b;
}
}
public class sample {
public static void main(String args[]) {
A pl, p2;
p2 = new A(12, 15);
p1 = p2; p2.x++;
System.out.println("p1.x=" + p1 .x);
}
}
参考答案: