单项选择题
现有:
1. interface Animal {
2. void eat();
3. }
4.
5. // insert code here
6.
7. public class HouseCat extends Feline {
8. public void eat() { }
9. }
和五个声明:
abstract class Feline implements Animal { }
abstract class Feline implements Animal { void eat(); }
abstract class Feline implements Animal { public void eat(); }
abstract class Feline implements Animal { public void eat() { } }
abstract class Feline implements Animal { abstract public void eat(); }
分别插入到第5行,有几个可以通过编译?()
A.0
B.1
C.2
D.3
相关考题
-
单项选择题
现有: 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
