Java程序设计第五章继承、接口和抽象类程序阅读题及答案.docx

上传人:李司机 文档编号:6798526 上传时间:2024-02-22 格式:DOCX 页数:13 大小:17.97KB
返回 下载 相关 举报
Java程序设计第五章继承、接口和抽象类程序阅读题及答案.docx_第1页
第1页 / 共13页
Java程序设计第五章继承、接口和抽象类程序阅读题及答案.docx_第2页
第2页 / 共13页
Java程序设计第五章继承、接口和抽象类程序阅读题及答案.docx_第3页
第3页 / 共13页
Java程序设计第五章继承、接口和抽象类程序阅读题及答案.docx_第4页
第4页 / 共13页
Java程序设计第五章继承、接口和抽象类程序阅读题及答案.docx_第5页
第5页 / 共13页
点击查看更多>>
资源描述

《Java程序设计第五章继承、接口和抽象类程序阅读题及答案.docx》由会员分享,可在线阅读,更多相关《Java程序设计第五章继承、接口和抽象类程序阅读题及答案.docx(13页珍藏版)》请在三一办公上搜索。

1、Is现有publicclassParetpublicvoidchange(intx)publicclassChildextendsParent/覆盖父类change方法)下列哪个声明是正确的覆盖了父类的change方法?A.publicvoidchange(intx)B.protectedvoidchange(itx)C.publicvoidchange(Strings)D.publicvoidchange(itx,inty)正确答案:A2、classCaintnum=1;Ca(itm)this.nur=num;System.out.prit(this.num);classCbextendsC

2、aitnum=2;Cb(itnum)this.nur=num;System.out.prit(um);)publicstaticvoidmain(Strigargs)Caa=newCb(5);)运行代码,程序输出结果为:A.52B.51C.编译报错D.15正确答案:C3、下面关于继承的叙述正确的是()AJava类中只允许单一继承BJava中一个类不能同时继承一个类和实现一个接口CJava中一个类只能实现一个接口DJava中一个类可继承于多个类正确答案:A4、给定下列程序,请选出正确结果。classCatCat(itc)System.out.print(cat+c+);)classSubCate

3、xtendsCatSubCat(itc)super(5);System.out.print(cable);)SubCat()this(4);)publicstaticvoidmain(String口args)SubCatS=newSubCat();)A.cablecat5B.cableC.cat5D.cat5cable正确答案:D5、下列程序的输出是()。classOtherpublicOther()System.ot.prit(Other!);)publicclassDriverlextendsOtherpublicstaticvoidmai(Stringargs)newDriverl();

4、newOther();)A.0ther!0ther!B.Other!C.Other!Other!Other!D.编译出错正确答案:A6、请选出以下程序的输出结果classApublicvoidfcl()System.out.pritln(,Afundiscalling);)publicvoidfc2()fucl();)classBextendsApublicvoidfcl()System.out.pritln(,Bfundiscalling);)publicvoidfc3()System.out.pritln(,Bfuc3iscalling);)classCpublicstaticvoidma

5、in(Strigargs)Aa=newBQ;a.fucl();a.fuc2();a.fuc3();)A. AfundiscallingBfc3iscallingB. BfundiscallingBfc3iscallingC. AfundiscallingAfundiscallingBfc3iscallingD.编译错误正确答案:D7、请选出以下程序的输出结果publicclassChildextendsPeoplePeoplefather;publicChild(Stringname)System.out.prit(3);this.ame=name;father=newPeople(name+

6、:F);)publicChild()System.out.prit(4);)publicstaticvoidmain(Stringargs)newChild(Alice);)classPeopleStringname;publicPeopIeQSystem.out.prit(l);)publicPeople(Stringname)System.out.prit(2);this.ame=name;)A.123B.132C.32D.312正确答案:B8、请选出正确答案classParentStringone,two;publicParet(Striga,Stringb)one=a;two=b;pu

7、blicvoidprint()System.ot.printl(oe);)publicclassChildextendsParentpublicChild(Stringa,Stringb)super(a,b);)publicvoidprit()System.out.pritln(oe+,to+two);)publicstaticvoidmai(Stringarg)Parentp=newParet(south,north);Parentt=newChild(,east,west);p.print();t.prit();)A. southtonortheasttowestB. southeastt

8、owestC. Causeerrorduringcompilation.D. D.southtonortheast正确答案:B9、请选择正确的输出结果classGuypublicGuy()System.out.prit(,llll);)classCowboyextendsGuypublicCowboy()System.out.prit(2221);)classWranglerextendsCowboypublicWragler()System.out.prit(333l);)publicclassGreeting2publicstaticvoidmain(Stringargs)Guygl=ne

9、wGuy();Guyg2=newCowboy();Guyg3=newWrangler();)A.编译错误B.111,111,222,111,222,333,C.lll,111,222,222,333,D.llll222,333,正确答案:B10、给定以下程序classPencilpublicvoidwrite(Stringcontet)System.out.pritln(Write+cotet);)classRubberPenciIextendsPecilpublicvoidwrite(Stringcontet)System.out.pritln(,RubberWrite+cotet);publicvoiderase(Stringcotet)System.ot.printl(Erase+content);)执行下列代码的结果是哪项?Pencilp=ewPecil();(RubberPenciI)p).write(,Hello);A.RubberWriteHelloB.运行时抛出异常C.WriteHelloD.编译失败正确答案:B

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 生活休闲 > 在线阅读


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号