30. 已知:
class B {
int i;
B(int i) {
this.i = i;
}
}
class C extends B {
public static void main(String[] args) {
C c = new C(1);
System.out.println(c.i);
}
}
的输出为
(A)0
(B)1
(C)编译错误
(D)运行时错误
31. 已知:
class C {
int x;
String y;
public C() {
this( “1”);
System.out.print(“one “);
}
public C(String y) {
this(1, “2”);
System.out.print(“two “);
}
public C(int x, String y) {
this.x = x;
this.y = y;
System.out.print(“three “);
}
public static void main(String[] args) {
C c = new C();
System.out.println(c.x + ““ + c.y);
}
}
则输出为
(A)1 2 one two three
(B)1 2 three two one
(C)one two three 1 2
(D)three two one 1 2
|
|