哪个选项可以用在“// 赋值x=a, y=b”位置上( )
public class Base
{ int x, y ,z, w;
public Base(int a,int b) { x=a; y=b; }
public Base(int a, int b, int c, int d)
{ // 赋值x=a, y=b
z=c; w=d;
}
}
A) x=a , y=b; B) Base (a,b); C) super (a,b); D) this (a,b);
public class Base
{ int x, y ,z, w;
public Base(int a,int b) { x=a; y=b; }
public Base(int a, int b, int c, int d)
{ // 赋值x=a, y=b
z=c; w=d;
}
}
A) x=a , y=b; B) Base (a,b); C) super (a,b); D) this (a,b);
1、A是不对的。因为里面的',',要改为';'
2、D是对的。它将调用构造方法Base(int a,int b)