如果您无法下载资料,请参考说明:
1、部分资料下载需要金币,请确保您的账户上有足够的金币
2、已购买过的文档,再次下载不重复扣费
3、资料包下载后请先用软件解压,在使用对应软件打开
面向对象编程(1)GiventhefollowingJavacode:classAnimal{publicStringnoise(){return"peep"}}classDogextendsAnimal{publicStringnoise(){return"back";}}classCatextendsAnimal{publicStringnoise(){return"move";}}...Animalanimal=newDog();Catcat=(Cat)animal;System.out.printIn(cat.noise());Whatistheresult?A.peepB.backC.moveD.Compilationfails.E.Anexceptionisthrownatruntime(2)GiventhefollowingJavacode:10.11.12.13.14.15.16.interfaceA{publicintgetValue();}classBimplementsA{publicintgetValue(){return1;}}classCextendsB{//insertcodehere}Whatthreecodefragmentsinsertedindividuallyatline15,makeusedofpolymorphism?(choosethree)A.publicvoidadd(Cc){c.getValue();}B.publicvoidadd(Bb){b.getValue();}C.publicvoidadd(Aa){a.getValue();}D.publicvoidadd(Aa,Bb){a.getValue();}E.publicvoidadd(Cc1Cc2){c1.getValue();}(3)AddmethodstotheBetaclasstomakeitcompilecorrectly.classAlpha{publicvoidbar(int…x){}publicvoidbar(intx){}}publicclassBetaextendsAlpha{placehereplacehereplacehere}Methodsprivatevoidbar(intx){}publicvoidbar(intx){}publicintbar(Stringx){return1;}publicAlphabar(intx){}publicvoidbar(intx,inty){}publicintbar(intx){returnx;}(4)GiventhefollowingJavacode:classTest1{publicTest1foo(){returnthis;}}classTest2extendsTest1{publicTest1foo(){returnthis;}}classTest3extendsTest2{//insertmethodhere}Whichtwomethods,insertedindividually,correctlycompletetheTest3class?(choosetwo)A.publicvoidfoo(){}B.publicintfoo(){return3;}C.publicTest2foo(){returnthis;}D.publicTest1foo(){returnthis;}(5)GiventhefollowingJavacode:publicclassBootchy{intbootch;Stringsnootch;publicBootchy(){this("snootchy");System.out.print("first");}publicBoothchy(Stringsnootch){this(420,"snootchy");System.out.print("second");}publicBootchy(intbootch,Stringsnootch){this.bootch=bootch;this.snootch=snootch;System.out.print("third");}publicstaticvoidmain(String[]args){Bootchyb=newBootchy();System.out.print(b.snootch+""+b.bootch);}}Whatistheresult?(运行结果)(6)GiventhefollowingJavacode:09.10.11.12.13.14.15.16.17.