scjp_-面向对象编程.pdf

scjp_-面向对象编程.pdf

ID:52239834

大小:398.13 KB

页数:18页

时间:2020-03-25

scjp_-面向对象编程.pdf_第1页
scjp_-面向对象编程.pdf_第2页
scjp_-面向对象编程.pdf_第3页
scjp_-面向对象编程.pdf_第4页
scjp_-面向对象编程.pdf_第5页
资源描述:

《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

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。