《2012-2013(一)ssd3考试试卷B.docx》由会员分享,可在线阅读,更多相关《2012-2013(一)ssd3考试试卷B.docx(7页珍藏版)》请在第壹文秘上搜索。
1、总分四五东北大学考试试卷(B卷)20122013学年第一学期课程名称:面向对象程序设计II.SingleChoice(20points,2pointeach)IConsiderthefollowingJavaprogramsegment.()intx=5;inty=2;System.out.println(x+y);(A) Theoutputcausedbythecodewillbe512.(B) Theoutputcausedbythecodewillbe512.(C) TheoutputcausedbythecodewillbeH.(D) Thecodewillcauseampilatio
2、nerror.2UMLclassdiagramscandescribewhichofthefollowing?()I. TheinternalstructureofclassesII. Relationshipsbetweenclasses(八)11only(B)Ionly(C)IandIl(D)None3WhenasubclassdefinesaninstancemethodwiththeSalnereturn(yeandsignatureasaInelhodinitsparent,theparentsmethodissaidtobe:()(八)overridden(B)overloaded
3、(C)private(D)hidden4Anobjectthatcontainsnwthodsthattraverseacollectionlinearlyfromstart(ofinishisknownasa(n)(八)loop(B)in(C)iterator(D)Exception5 WhichofthefollowingistrueaboutassociationandaggregationinUMLclassdiagrams?(A) Associationandaggregationhavenomeaningfulrelationship.(B) Associationisaspeci
4、alformofaggregation.(C) Associationistheoppositeofaggregation.(D) Aggregationisaspecialformofassociation.6 Inanobjectnxiel.thedatathatanobjectisresponsibleformaintainingarerepresentedby(八)generalizations(B)attributes(C)methods(D)SPCCialiZat沁ns7 Whenusingnoun-phraseanalysistomodelasoftwaresystem,whic
5、hofthefollowingshouldtypicallybeeliminatedfromthelistofpotentialclasses?()I. Referencesto(hesoftwaresystemitselfII. Nouns(hatimplyrolesbetweenobjectsIII. Synonymstoothernounsinthelist(八)Iand111only(B)111only(C)I,ILand111(D)11and111only8WhaiistherightwaytohandleabnormalitiesininputonJava?()(A) Byalwa
6、ysspecifyingthethrowsclauseineverymethodheaderwherefileI/Oisperformed(B) ByusingtheclassEiIeFiIterwhichgracefullyfiltersoutbadinputdata(C) Byhandlingtheseproblemsbyprovidingexceptionhandlers(D) Bywritingwhileloopstoguardagainstbadinput9Acomponentcanberesizedhorizontally,butnotvertically,whenitisplac
7、esinwhichregionofaBorderLayout?()(八)NorthorSouth(B)EastorWest(C)Center(D)North.SouthorCenterIOWhichofthefollowingistrueregardingIhecontrollerpartintheModel-fiew-Cvninzller(MVC)paradigm?()(A) ,hecontrolleristheabstractdomainknowledgeofanapplication.(B) ThecontrolleristheautomaticmechanismbywhichIheus
8、erinterfaceisdisplayedandbywhicheventsarecommunicatedbetweenthemodelandtheview.(C) Tecontrolleristhelistofabstractclassesinanapplication.(D) ThecontrolleristhewayinwhichtheabstractdomainknowledgeofanapplicationispresentedtotheuserII.Fillinblankandcopletethefollovingprograas.ClassFileSysteaonlyhasone
9、instanceinantplication.(10points*2pointeach)publicclassFiIeSystemprivateHIeSystemSingIeFiIeSystem=null;RleSystem()(IpublicstaticFiIeSystemgetSingleFileSystem()if()(SingIeFiIeSystem=:Ireturn;)III. AccordingtoUMLclassdiagraa,seeFig1.IinplesentstheHunanResourceInformationsystem.Theipleentationvillconsi
10、stofthreeclasses.(20points)Fig1HumanResourceInformationSystemClassDiagramNote:InclassEmployeetoString():overridesthemethodIoStringintheclassObject.ReturnsthestringrepresentationofanEmployeeobject.Thestringreturnedhasthefollowingformat: id,name,WeeklySalary ,hefieldsaresepa,atedbyacomma(,).Youcanassu
11、methatthefieldsthemselvesdonotcontainanycommas.IV. Inthisexaa,youvillcreateanaddressbk)plicationvithaSvingGUI.Partoftheworkhasbeendoneforyou.Youvillimplementthecodethathandlesthebuttonevents.(20points)Fig2AddressBookGUI(1)ImplenennetholactionPerfbmedin(heinnerclassOpenButtonListener:Beginbyremovinga
12、llentriesintheaddressbookifithasanyandclearingthestatusarea.Next,loadthedataintheSPCdfiedfileintothenow-emptyaddressbook.Everylinein(hefileshouldcontainexactlyoneaddressbkentrywiththefollowingformat:name_addressJelephonewhere: *nameisastringthatrepresentsthenameoftheentry.令addressisastringthatrepres
13、entstheaddressoftheenty. telephonei$asiringthatrepresentsIhetelephoneoftheenry.Thefieldsaredelimitedbyanunderscore(_).Tosimplifyyourcode,youcanassumethatthefieldsthemselveswillnotcontainanyunderscores.UsetheclassStdngTCkeniZertoextracttheentryfields.Afterloadingthedataintotheaddressbk.displaythename
14、softhepeopleintheJList.UsethemethodAddressBook.geNamestoobtainanarrayof(henames.Usethemetheandthenoutputastatusmessagein(hes(a(usarea.Thismethodshoulddisplayanerrormessageinthestatusareawhenitdetectsoneof(hefollowingerrors:令Theaddressbookisempty.Theuserha$tselectedaname.班级O*Thisinnerclasshandlescdis