2012-2013(一)ssd3考试试卷A.docx
-
资源ID:824615
资源大小:73.26KB
全文页数:10页
- 资源格式: DOCX
下载积分:5金币
友情提示
2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
|
2012-2013(一)ssd3考试试卷A.docx
总分四五东北大学考试试卷(A卷)20122013学年第一学期课程名称:面向对象程序设计II!.SingleChoice(20POilItS2pointseach)1Fromwithinachildclass,itsparentclassisreferredtoviathekeyword?(C)(八)(his(B)Base(C)Super(D)parent2ClassesfromwhichofthefollowingpackagesareimplicitlyimportedintoeveryJavaprogram?(A)(八)java.Iang(B)java.util(C)java.awt(D)java.io3InJava,thedefaultlayout布局managerforaJPaneIcomponentis(D)(八)BorderLayout(B)GridLayout(C)GridBagLayout(D)FIowLayout4TheStrategy策略designpattern模式islikelytobeusefulwhenimplementingwhichofthefollowing?(B)1Anapplicationthatoffersseveralalternate交替sorting排J至algorithms算法IlAsimpleclasstostoretheaddressofanorganizationofwhichonlyoneinstancecanbeinstantiated(八)None(B)1only(C)IIonly(D)1andIl5IfthelengthofaparticulararrayisthevalueofLIMIT,whatistheindex指针ofthelastiteminthatarray?(D)(八)LIMIT(B)O(C)LIMIT/2(D)LIMIT-I8Ifafileopenedforreadingdocsnotexist,whichofthefollowingeventswilloccurinJava?(D)(A) ANulipoinierExcepiionwillberaised.(B) Anewfilewillbecreated(C) Arun-timeerrorwilloccur(D) AFilcNotFoundExccptionwillberaised.9Adesignpatternistypicallyusedlo(D)(A) allowtheuseofobject-orientatedconceptsinalanguagethatisnotobject-oriented(B) reducethenumberofclassesinthedesignofaprogram(C) ensurethatcodeexecutesatoptimalspeedduringntimc(D) describeapracticalsolutiontoaCOmmOndesignproblem10Whichofthefollowingstatementsis(are)teinJava?(B)IClassesthatcontainabstractmethodsmustbedeclaredabstract.IIClassesthatcontainprotectedmethodsmustbedeclaredabslct.(八)1andIl(B)Ionly(C)IIonly(D)NoneH. Fill in blanks. (10 points* 1 point each )6 Whichofthefollowingstatementsisnottrueofleclassjava.util.ArrayList?(B)(A) AninstanceofArrayListcangrowtoaccommodatenewitemswhenthecollectionisfull.(B) Onceanobjectisinsertedinto插入aninstance实例OfArrayList.itcanneverberemoved.(C) ItemsstoredbyaninstanceofArrayListcanbeaccessedusingintegerindexes.(D) TheconstructoroftheAayListclass,whencalledwithnoarguments,causesanemptyArrayListtobeconstructed.7 ACOneCtiOn聚集IyPiCanymOdekarelationship?(C)(八)many-(o-many(B)zcro-(o-onc(C)one-to-many(D)one-to-one1 A单例designpatternCansuretomakeonlyoneobjectinthesoftwaresystem.2 InaUMLclassdiagram'srepresentationofaclass,(hetop.middle,andlowerrectangularcompartmentsrespectivelydescribethe类名称.属性and方法oftheclass.3 Inanobjectmodel,thedatathatanobjectisresponsibleformaintainingarcrepresented描写by届性.4 Thedatainainterfacemustbe共有的and抽象的.5 封装,继承and多态arcthebasecharactersofObject-OrientedProgramming.publicinterfaceMemberStrategypublicdoublecalcPrice(doublebooksPrice);publicclassPriceprivateMemberStrategystrategy;publicPrice(MemberStrategystrategy)this.strategy=strategy;)publicdoublequote(doublebooksPrice)returnthis.strategy.calcPrice(bksPrice);)publicclassNonnalMeniberStrategyimplementsMemberStrategypublicdoublecalcPrice(doublebooksPrice)SySlem.oulprinlln("对于初级会员的没有折扣");returnbooksPrice;)publicclassVIPMemberStrategyimplementsMemberStrategypublicdoublecalcPrice(doublebooksPrice)SySIem.oulprinlln("对于中级会员的折扣为10%");returnbooksPrice*0.9;)publicclassSuperMemberStrategyimplementsMemberStrategypublicdoublecalcPrice(doublebooksPrice)SySlem.oulprinln("对于高级会员的折扣为20%");returnbooksPrice*0.8;)(f)III. DesignasimpleBookSellerSystemwithstrategypattern.(25points)(a) Youdon'tcareallthefunctionsofthesystem.(b) TherearethreekindsofclientwhichincludeVIPMember(0.9*price).NorniaIMemberf1eprice),SuperMember(0.8*price).Theyhavethedifferentdiscountwhentheybuybookfromthesystem.Youmustusestrategypatternwhenyoudesignthesystem.Firstly,youshouldgive(heUMLclassdiagramiththestrategypattern策略模式.(5points)Secondly,youshouldwritethecodeforeachclassyoudesignintheUML.(15points)Thirdly,youshouldwriteaclassnamedTestwhichincludeamain()method,wesupporttherearethreeclientsnamedTom(VIPMember),John(NormaIMember)andMike(SuperMember).Theclassyouwritecansellabooktothethreeclients.Wesupportthepriceofthebookis150.(5points)YourUMLishere.第3题答案:UML图(5points)IV. CreateanStudentinformationManagementapplicationasshownFig.1usingSwingGUI.Partoftheworkhasbeendone.Youshouldfinishthecode.(30points)Fig1StudentInfornwtionMHnagenIenlApplicationimportjava.aw.4;importjava.aw(.event.ActionListener;importjava.aw(.event.ActionEvent;importjava.io.FilcNotFondExccption;importjava.io.FileOutputStream;inpo11java.io.PriniWriter;importjavax.swing.*;*Demonstratesthecomponent(g>linkJTcxtFicId).Thisclassextendsclass(linkJPanel).*/publicclassStudentManagcnwntextendsJPaneIprivateJLabeIIabelName:privateJLabcIIabcINo;privateJLabeIIabeIGender:PriVaIeJlexiFieIdIextFieIdName;privateJTextFieIdIextFieIdNo;privateJTextFieldIextFieidGender:JButtonUddSIudentBUtton;JButtonsbmitButton;publicstaticvoidmain(Stringargs)JFrameframe=newJFramec'学生信息增):frame.setContentPane(newStude