欢迎来到天天文库
浏览记录
ID:52239834
大小:398.13 KB
页数:18页
时间:2020-03-25
《scjp_-面向对象编程.pdf》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、Module03-面向对象编程一、选择题:Question1Given:20.publicclassCreditCard{21.22.privateStringcardlD;23.privateIntegerlimit;24.publicStringownerName;25.26.publicvoidsetCardlnformation(StringcardlD,27.StringownerName,28.Integerlimit){29.this.cardlD=cardlD;30.this.ownerName=owner
2、Name;31.this.limit=limit;32.}33.}Whichistrue?A.Theclassisfullyencapsulated.B.Thecodedemonstratespolymorphism.C.TheownerNamevariablebreaksencapsulation.D.ThecardlDandlimitvariablesbreakpolymorphism.E.ThesetCardlnformationmethodbreaksencapsulation.Answer:CQuestion2W
3、hichtwoaretrue?(Choosetwo.)A.Anencapsulated,publicclasspromotesre-use.B.Classesthatsharethesameinterfacearealwaystightlyencapsulated.C.Anencapsulatedclassallowssubclassestooverloadmethods,butdoesNOTallowoverridingmethods.D.Anencapsulatedclassallowsaprogrammertocha
4、ngeanimplementationwithoutaffectingoutsidecode.Answer:ADQuestion3Assumethatcountryissetforeachclass.Given:10.publicclassMoney{11.privateStringcountry,name;12.publicgetCountry(){returncountry;}CopyrightTarenaCorporation,2008.Allrightsreserved13.}and:24.classYenexte
5、ndsMoney{25.publicStringgetCountry(){returnsuper.country;}26.}27.28.classEuroextendsMoney{29.publicStringgetCountry(StringtimeZone){30.returnsuper.getCountry();31.}32.}Whichtwoarecorrect?(Choosetwo.)A.Yenreturnscorrectvalues.B.Euroreturnscorrectvalues.C.Anexceptio
6、nisthrownatruntime.D.YenandEurobothreturncorrectvalues.E.Compilationfailsbecauseofanerroratline25.F.Compilationfailsbecauseofanerroratline30.Answer:BEQuestion4Given:10.interfaceA{voidx();}11.classBimplementsA{publicvoidx(){}publicvoidy(){}}12.classCextendsB{public
7、voidx(){}}And:20.java.util.Listlist=newjava.util.ArrayList();21.list.add(newB());22.list.add(newC());23.for(Aa:list){24.a.x();25.a.y();26.}Whatistheresult?A.Thecoderunswithnooutput.B.Anexceptionisthrownatruntime.C.Compilationfailsbecauseofanerrorinline20.D.C
8、ompilationfailsbecauseofanerrorinline21.E.Compilationfailsbecauseofanerrorinline23.F.Compilationfailsbecauseofanerrorinline25.Answer:FCopyrightTarenaCor
此文档下载收益归作者所有