题目要求
本期题目:
1、(单选题)
What will be printed when you execute the following code?
class
C {
C() {
System.out.print("C");
}
}
class
A {
C c = new
C();
A() {
this("A");
System.out.print("A");
}
A(String s) {
System.out.print(s);
}
}
class
Test extends
A {
Test() {
super("B");
System.out.print("B");
}
public
static
void
main(String[] args) {
new
Test();
}
}
A、BB B、CBB C、BAB D、None of the above
2、(单选题)
以下程序执行的结果是:
class
X{
Y y=new
Y();
public
X(){
System.out.print("X");
}
}
class
Y{
public
Y(){
System.out.print("Y");
}
}
public
class
Z extends
X{
Y y=new
Y();
public
Z(){
System.out.print("Z");
}
public
static
void
main(String[] args) {
new
Z();
}
}
A、ZYXX B、ZYXY C、YXYZ D、XYZX
3、(不定项选择题) 以下关于final关键字说法错误的是 A、 final是java中的修饰符,可以修饰类、接口、抽象类、方法和属性 B、 final修饰的类肯定不能被继承 C 、final修饰的方法不能被重载 D、 final修饰的变量不允许被再次赋值 读者可在右下角的留言留下你的答案以及理由!
上期练习题答案公布栏