单项选择题
现有:
class Cat {
Cat(int c) { System.out.print("cat" + c + " "); }
}
class SubCat extends Cat {
SubCat(int c) { super(5); System.out.print("cable "); }
SubCat() { this(4); }
public static void main(String [] args) {
SubCat s = new SubCat();
}
}
结果为:()
A.cat5
B.cable
C.cable cat5
D.cat5 cable
点击查看答案&解析
相关考题
-
单项选择题
class Dog { } class Harrier extends Dog { } class DogTest { public static void main(String [] args) { Dog d1 = new Dog(); Harrier h1 = new Harrier(); Dog d2 = h1; Harrier h2 = (Harrier) d2; Harrier h3 = d2; } } 下面哪一项是正确的?()
A.编译失败
B.2个Dog对象被创建
C.2个Harrier对象被创建
D.3个Harrier对象被创建 -
单项选择题
现有: class ThreadExcept implements Runnable { public void run() { throw new RuntimeException("exception "); } public static void main(String [] args) { new Thread(new ThreadExcept()).start(); try { int x = Integer.parseInt(args[0]); Thread.sleep(x); System.out.print("main "); } catch (Exception e) { } } } 和命令行: java ThreadExcept 1000 哪一个是结果?()
A. main
B. 编译失败
C. 代码运行,但没有输出
D. main java.lang.RuntimeException: exception -
单项选择题
程序员想要创建一个名为MyThread的类以便在main方法中用Thread实例化。对于下面三行: MyThread必须继承Thread。 MyThread必须实现Thread。 MyThread必须覆盖public void run()。 有几行是正确的?()
A. 0
B. 1
C. 2
D. 3
