06接口与内部类

上传人:jiups****uk12 文档编号:40098679 上传时间:2018-05-23 格式:DOC 页数:4 大小:48.50KB
返回 下载 相关 举报
06接口与内部类_第1页
第1页 / 共4页
06接口与内部类_第2页
第2页 / 共4页
06接口与内部类_第3页
第3页 / 共4页
06接口与内部类_第4页
第4页 / 共4页
亲,该文档总共4页,全部预览完了,如果喜欢就下载吧!
资源描述

《06接口与内部类》由会员分享,可在线阅读,更多相关《06接口与内部类(4页珍藏版)》请在金锄头文库上搜索。

1、1.给出如下层次图和程序片段,下列哪个命题是正确的?【选择一项】AnimalMammalDog Cat Raccoon Elephant(implements) (implements) ( Washer ) ( Washer ) 1.Cat sunflower; 2.Washer wawa; 3.Elephant pogo; 4. 5.sunflower = new Cat(); 6.wawa = sunflower; 7.pogo = (Elephant)wawa;A第 6 行导致程序编译失败。 B第 7 行导致程序编译失败。 C编译通过但是第 7 行会抛出异常。 DD以上结果均不是。2.

2、下列那些命题是不正确的?【选择两项】 AJAVA 程序通过接口实现多重继承。 BJAVA 里面所有的异常、接口或者其他类,都从 Object 类扩展而来。 C构造方法可以用 private 修饰,并且可以抛出异常。 D装箱类一共有六个。3.下列哪些命题为假?【选择三项】 A静态方法只能被类调用,不能被实例调用。 B所有数据类型都可以用=判断恒等。 Cequals()方法成立的地方,=也一定成立。 D包含抽象方法的类一定是抽象类。4.试图编译、运行下列程序,结果是什么?【选择一项】 /Foo.java interface Foo int k = 0; /Test.java public clas

3、s Test implements Foo public static void main(String args) int i; Test test = new Test(); i = test.k; i = Test.k; i = Foo.k; A编译失败。 B编译成功。 C运行异常。 D以上结果均不是。5.下列修饰符不能用于顶层类的是哪个【选择一项】 。Apublic Bprivate Cabstract Dfinal6.哪些命题为真?【选择两项】 A在 Java 中,implement 用于实现接口。 B非抽象类的子类可以声明为 abstract。 C超类的所有成员都将由子类继承。 D

4、final 类不可以是抽象的。 E如果类中的所有成员都声明为 private,则该类不能声明为 public。7.哪些关于接口的命题为真?【选择两项】 A接口允许多重实现接口。 B接口可以被任意数目的其他接口扩展。 C接口可以扩展任意数目的其他接口。 D接口的成员变量从来不会是 static。 E接口的方法总会被声明为 static。8.给出下面的程序: 1. interface Base 2. boolean m1 (); 3. byte m2(short s); 4. 下面哪两段代码将编译通过? 【选择两项】 Ainterface Base2 implements Base Babstra

5、ct class Class2 extends Base public boolean m1() return true; Cabstract class Class2 implements Base Dabstract class Class2 implements Base public boolean m1() return (7 4); Eclass Class2 implements Base boolean m1() return false; byte m2(short s) return 42; 9.给出下面的代码: 1. interface Animal 2. void so

6、undOff(); 3. 4. 5. class Elephant implements Animal 6. public void soundOff() 7 . System.out.println(“Trumpet”); 8. 9. 10. 11. class Lion implements Animal 12. public void soundOff() 13. System.out.println(“Roar”); 14. 15. 16. 17. class Alphal 18. static Animal get(String choice) 19. if (choice.equa

7、lsIgnoreCase(“meat eater”) 20. retum new Lion(); 21 else 22 retum new Elephant(); 23 24 25 哪条语句能够正确编译? 【选择一项】 Anew Animal().soundOff(); BElephant e =new Alphal(); CLion l=Alpha.get(“meat eater”); Dnew Alphal().get(“veggie”).soundOff();10. 给出下面的程序:【选择一项】 1.class Foo 2. class Bar 3. 4.class Test 5. pu

8、blic static void main (String args) 6. Foo f = new Foo(); 7. / 8. 9. 哪一条语句插入第7行能创建一个Bar实例? AFoo.Bar b = new Foo.Bar(); BFoo.Bar b = f.new Bar(); CBar b = new f.Bar(); DBar b = f.new Bar(); EFoo.Bar b = new f.Bar();11. 给出下面的代码: 1. public interface Foo 2. int k = 4; 3. 哪三条语句等价于第 2 行语句? 【选择三项】 Afinal int k = 4; Bpublic int k = 4; Cstatic int k = 4; Dabstract int k = 4; Evolatile int k = 4; Fprotected int k = 4;

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 中学教育 > 其它中学文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号