《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
15、playButtoncevents.classDisplayButtonLis(enerimplementsActionListener/* Displaystheaddressbookentryfortheselectedperson.* parameventtheeventobject.* /publicvoidactionPerfrmed(ActionEventevent)*PLACEYOURCODEHERE*/学院*ThisinnerclasshandlesopenButtonevents./classOpenButtonListencrimplementsActionListener
16、班级C)严* Loadsaddressbookdatafromthespecifiedfileanddisplays* Ihenamesinalist.Alsodisplays,beneaththelist,thenumber2学号*ofnamesintheaddressbook.*parameventtheeventobject.*/姓名publicvoidactionPerformed(AciionEvenlevent)*PLACEYOURCODEHERE*/V.ReadingtheVideoRentalSystemSpecificationandcreateaUMLclassdiagra
17、mforthissystem.(30points)VideoRentalSystemSpecificationThevideorentalsystemmaintainscustomers,videosandrentalrecords.Newcustomersmayregisterasusersofavideorentaloutletbysupplyingtheirdetailssuchasname,addressandtelephonenumber.Then,toeachnewcustomer,thesystemdistributesarentalcardwithabarCode(条形码)re
18、presentingtheiruniqueidentificationnumber.Eachvideoalsopossessesabarcoderepresentingitsuniqueidentificationnumber.Whenacustomerwishestorentavideo,theypresenttheirrentalcard,togetherwiththechosenvideo.Arentalrecordisaddedtothesystem.Whenavideoisreturnedbyacustomer,thevideosbarCodeisscannedsothatthesy
19、stemsrecordscanbeupdatedasnecessary.Thesystemcanaddvideosto.orwithdrawvideosfrom,therecordedstockbysupplyingappropriatedetails.Inaddition,thesystemcanprluceamanagementreport,onrequest,inordertoidentifythemostandleastpopularvideos.Internallythesystemstorescustomerdetailsinadatabase.Thevideodetailsare
20、alsorecordedinadatabase.Theinfbnationforeachvideoalsoincludesidentificationnumber,type(movies,TVshows,etc.),title,perfbner,publishedyear,rentalprice,format(DVD,VCD,etc.),andstatus(inshop,outonrental,orwithdrawn).Thesystemhastomaintaineveryrentalrecording.Aseparaterentalrecordingkeepsdetailsofeachvid
21、eorentalwithinformationthatincludesdateandtimeofrentalandreturn,customerandvideo.Inthevideorentalsystem,theusershouldbeableto: Displaythevideosbylistingthecode,title,andavailabilityofeachvideo. Displaythedetailsofavideo. Displaythecustomersbylistingtheidentificationcodeandnameofeachcustomer.令Displaythevideosrentedbyacustomer. Rentavideo. Returnavideo.