第六章练习题(抽象类与接口)
1.下列有关抽象类的叙述正确的是哪项?
A.抽象类中一定含有抽象方法
B.抽象类的声明必须包含abstract关键字
C.抽象类既能被实例化也能被继承
D.抽象类中不能有构造方法
2.下列有关抽象方法叙述正确的是哪项?(选两项)
A. 抽象方法和普通方法一样,只是前面多加一个修饰符asbtract
B.抽象方法没有方法体
c.抽象方法可以包含存任何类中
D.包含抽象方法的类的具体子类必须提供具体的覆盖方法
3.下列有关接口的叙述错误的是哪项?
A.接口中只能包含抽象方法和常量
B.一个类可以实现多个接口
C.类实现接口时必须实现其中的方法
D.接口不能被继承
4.下列关于接口的定义哪项是正确的?
A. interface C{int a;)
B. public interface A implements B {)
C. public interface A {int a(); )
D. abstract interface D {)
5.现有:
1. interface Animal f
2. void eat();
3. }
4.
5. // insert code here
6.
7. public class HouseCat implements Feline {
8. public void eat() { }
9. }
和以下三个接口声明:
interface Feline extends Animal ( )
interface Feline extends Animal {void eat(); }
interface Feline extends Animal {void eat() { } }
分别插入到第5行,有多少行可以编译?
A. 0
B. 1
C. 2
D. 3
6.现自:
1. interface Color { }
2. interface Weight { }
3. //insert code here
和以下足六个声明:
class Boat extends Color, extends Wei