雨课堂学堂在线学堂云《Java Programming(浙江工业大学)》单元测试考核答案_第1页
雨课堂学堂在线学堂云《Java Programming(浙江工业大学)》单元测试考核答案_第2页
雨课堂学堂在线学堂云《Java Programming(浙江工业大学)》单元测试考核答案_第3页
雨课堂学堂在线学堂云《Java Programming(浙江工业大学)》单元测试考核答案_第4页
雨课堂学堂在线学堂云《Java Programming(浙江工业大学)》单元测试考核答案_第5页
已阅读5页,还剩17页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

JavaProgramming第1题Javaisredesignedandimprovedfromthe()language.AAdaBCCPascalDBasic第2题WhichofthefollowingisnotafeatureoftheJavalanguage?APlatformindependenceBObject-orientedCSupportspointertypesDGarbagecollectionmechanism第1题Whichofthefollowingisavalidvariabledeclarationidentifier?()A&ABVariableBC+CD-D第2题WhichofthefollowingisavalidJavaidentifier?()AcatB5booksC+staticD-3.14159第3题WhichofthefollowingisaprimitivedatatypeinJava?AStringBIntegerCintDFloat第4题Whichofthefollowingoperatorsislegal?A&Bc.CifD:=第5题breakstatement()AOnlyinterruptstheinnermostloopBOnlyinterruptstheoutermostloopCWiththehelpoflabels,caninterruptanyouterloopDOnlyinterruptsacertainlayerofloop第6题Whichstatementisusedtoterminatethecurrentloopandexittheouterloop?AbreakBcontinueCexitDreturn第7题WhichofthefollowingcanbeusedasacorrectvariablenameinJava?()A3DBnameCextendsDimplements第8题DefinethestringStrings1="hello";:Whichofthefollowingdescriptionsoftheprogramiscorrect?if(s1=="hello"){System.out.println("s1="hello"");}else{System.out.println("s1!=hello");}AOutputs1!=helloBOutputs1="hello"CGeneratecompilationerrorDCompilescorrectlybutrunswitherrortest第1题WhichofthefollowingdefinitionsofclassMyClassiscorrect?()ApublicclassMyClassextendsClass1,Class2BpublicclassMyClassextendsInterface1implementsClass1CpublicclassMyClassextendsInterface1,Interface2DpublicclassMyClassimplementsInterface1,Interface2第2题Whichofthefollowingisnotallowedasanaccesscontrolmodifierforclassesandclassmembers?()ApublicBprivateCstaticDprotected第3题Whenisaconstructorcalled?()AWhentheclassisdefinedBWhenanobjectiscreatedCWhenanobjectmethodiscalledDWhenanobject'svariableisused第4题ToconstructaninstanceoftheArrayListclass,whichmethodiscorrect?AArrayListmyList=newObject();BArrayListmyList=newArrayList();CmyList=newObject();DmyList=newArrayList();第5题Whichofthefollowingstatementsaboutconstructorsisincorrect?()AJavalanguagestipulatesthattheconstructornamemustbethesameastheclassnameBJavalanguagestipulatesthatconstructorshavenoreturnvalueandarenotdeclaredwithvoidCJavalanguagestipulatesthatconstructorscannotbeoverloadedDJavalanguagestipulatesthatconstructorscanonlybeautomaticallycalledthroughnew第6题Thecorrectdescriptionofthefinalkeywordis().Afinalcanmodifyclasses,methodsandvariablesBfinalcanonlymodifyvariablesCfinalcanonlymodifymethodsDfinalcanonlymodifyclasses第7题Whatistheoutputresultofthefollowingcode?(Understandingofthethiskeyword)classTest{intx;Test(intx){this.x=x;}voidshow(){System.out.println("x="+x);}publicstaticvoidmain(String[]args){Testt1=newTest(10);Testt2=newTest(20);t1.show();t2.show();}}Ax=10x=20Bx=10x=10Cx=20x=20Dx=0x=0第8题RegardingtheuseofthestatickeywordinJava,thecorrectstatementis:AUsedtodeclarethatamethodisstaticBUsedtodeclarethataclassisstaticCUsedtodeclarethatanobjectisstaticDUsedtodeclarethataconstructorisstatic第9题ThepackagethatprovidesJavawiththeabilitytoaccessdatabasesis:Ajava.sqlBjava.awtCjava.langDjava.swingtest第1题Whichofthefollowingstatementsaboutinheritanceiscorrect?()AInJava,aclasscaninheritfromoneclassandoneinterfaceatthesametimeBInJava,aninterfacecaninheritfrommultipleinterfacesatthesametimeCAsubclasscanonlyinheritthepublicmethodsandattributesofitsparentclassDAsubclasscanonlyinheritthemethodsofitsparentclass,nottheattributes第2题Giventhefollowingcode,howtomakethemembervariablembedirectlyaccessedbythemethodfun()?classTest{privateintm;publicstaticvoidfun(){}}AChangeprivateintmtoprotectedintmBChangeprivateintmtopublicintmCChangeprivateintmtostaticintmDChangeprivateintmtointm第3题WhichofthefollowingdescriptionsaboutthesuperkeywordinJavaiscorrect?()AsupercanbeusedtoaccessmembersofthesubclassBsuperisusedtoaccesstheconstructoroftheparentclassCsupercannotaccesstheprivatemembersoftheparentclassDsupercanreplacethistocallmembersofthecurrentclass第4题Ifthemethodmymethod()inasubclassoverridesthemethodmymethod()initsparentclass,andtheparentclassmethodisdefinedasfollows:voidmymethod(inta),whichofthefollowingdefinitionsofthesubclassmethodisillegal?()Apublicvoidmymethod(inta)Bprotectedvoidmymethod(inta)Cprivatevoidmymethod(inta)Dvoidmymethod(inta)第5题Whichofthefollowingisacorrectdescriptionofmethodoverloading?()AThereturnvaluetypesofoverloadedmethodsmustbedifferentBTheparameternamesofoverloadedmethodsmustbedifferentCThemodifiersofoverloadedmethodsmustbedifferentDTheparametersofoverloadedmethodsmustbedifferent(parametertype,numberofparameters,ororderofparametertypes)第6题Whichkeywordcanbeusedtopreventamethodfrombeingoverriddenbyasubclass?()AabstractBstaticCfinalDvolatile第7题Whichofthefollowingstatementsaboutabstractclassesandinterfacesiscorrect?()AAnabstractclasscanbeusedtodefineaninterfaceBAllmethodsinanabstractclassareconcrete(withimplementations)CAnabstractclasscanbeanimplementationofaninterfaceDTheabstractkeywordisrequiredwhendefininganabstractclass第8题InJava,whichinterfaceistheparentinterfaceofallcollectionclasses?()ACollectionBSetCListDIterable第9题Giventhefollowinginterfacedefinition:publicinterfaceA{StringDEFAULT_GREETING="HelloWorld";publicvoidmethod1();}Whichofthefollowingclassorinterfacedefinitionsiscorrect?()AabstractclassBimplementsA{abstractprotectedvoidmethod1();}BpublicinterfaceBextendsA{}CpublicinterfaceBimplementsA{}DclassBextendsA{publicvoidmethod1(){return;}}第10题ClassAderivesasubclassB,andBderivesasubclassC.Forthefollowing3linesofJavacode,whichstatementiscorrect?()Aa1=newA();Aa2=newB();Aa3=newC();ALines1,2,and3allcompilesuccessfully,butlines2and3throwerrorsduringruntimeBOnlyline1compilessuccessfullyCLines1and2compilesuccessfully,butline3failstocompileDThedeclarationsinlines1,2,and3areallcorrecttest第1题Whichofthefollowingstatementsaboutarraysiscorrect?()AThearraytypebelongstoprimitivetypesBAfteranarrayiscreated,itslengthcanbechangedCArrayelementscannotbeobjectsDOnceanarrayiscreated,itslengthcannotbemodified第2题Whichofthefollowingarraydeclarationsisincorrect?()Aint[]arry=newint[100];Bint[3]arry={1,2,3};Cint[]arry=newint[]{1,2,3};Dint[][]arry=newint[3][];第3题Whichofthefollowingarraydefinitionsfailstocompile?()Aint[]scores={80,85,87};Bint[][]scores={82,87,96},{92,83,45};CStringcats[]={"Fluffy","Spot","Zeus"};DIntegerresults[]={1,2,newInteger(3)};第4题InJava,whichmethodisusedtocomparewhetherthecontentsoftwostringsareequal?()A==BcompareTo()Cequals()Dcompare()第5题Thefollowingcodeisusedtocalculatethelengthofastring.Whichcodeshouldbefilledintheblank?()publicclassMain{publicstaticvoidmain(String[]args){Stringstr="HelloWorld!";intlength=0;//<insertcode>System.out.println("Length="+length);}}Alength=str.length();Blength=str.charAt(str.length());Clength=str.size();Dlength=str.length()-1;第6题Whichofthefollowingdefinitionsofatwo-dimensionalarrayiscorrect?()Aint[][]a=newint[][]Bint[][]a=newint[][5]Cinta[][]=newint[3][]Dinta[2][3]={{1,2,3},{4,5,6}}test第1题Regardingtheimportjava.utilpackage,whichofthefollowingstatementsisincorrect?()ATheVectorclassbelongstothejava.utilpackageBTheVectorclassislocatedinthe…/java/util/directoryCTheVectorclassisstoredinthejava.utilfileDTheVectorclassisaproductofSunMicrosystems第2题WhichpackageisimportedbydefaultbytheJavaVirtualMachine()?()Ajava.appletBjava.langCjava.ioDjava.awttest第1题Whichofthefollowingstatementsaboutexceptionsiscorrect?()AOnceanexceptionoccurs,theprogramexecutionterminatesimmediatelyBIfamethoddeclaresthatitwillthrowacertainexception,itmustactuallythrowthatexceptionCMatchingexceptionsinthecatchclauseisanexactmatchDMethodsthatmaythrowsystemexceptionsdonotneedtodeclaretheexceptions第2题WhichofthefollowingstatementsaboutJavaexceptionhandlingiscorrect?()AExceptionclassesarederivedfromtheThrowableclassBWhencatchingexceptions,multiplecatchblockscanbeused,buttherecanonlybeonefinallyblockCthrowisusedtodeclareexceptionsDthrowsisusedtothrowexceptions第3题Regardingtheexceptionhandlingstatementtry…catch…finally,whichofthefollowingstatementsiscorrect?()AtrycanbeusedaloneBIftherearemultiplecatchstatements,eachcatchthatmeetstheconditionswillbeexecutedonceCWhenanexceptionoccursintheprogram,afterfindingthecatchthatmeetstheconditions,thesubsequentcatchblockswillnotbeexecutedDOncethecatchblockisexecutedintheprogram,thefinallyblockwillnotbeexecuted第4题InJava,whichofthefollowingisthecorrectorderofexceptionhandlingkeywords?()Atry→catch→finallyBcatch→finally→tryCfinally→catch→tryDtry→finally→catch第5题Whattypeofexceptionoccursafterthefollowingcoderuns?()publicclassTest{publicstaticvoidmain(String[]args){for(inti=0;i<2;i++){System.out.println(args[i]);}}}Runningcommand:javaTesthelloAFirstoutputhello,thenanexceptionoccurs,andtheexceptiontypeisArithmeticExceptionBAnexceptionoccurs,andtheexceptiontypeisIOExceptionCFirstoutputhello,thenanexceptionoccurs,andtheexceptiontypeisArrayIndexOutOfBoundsExceptionDTheprogramoutputstheinformationhellonormallytest第1题Whichofthefollowingstreamsbelongstothecharacterstream?()AInputStreamBFileInputStreamCDataInputStreamDFileReader第2题RegardingJavainputandoutputstreams,whichofthefollowingstatementsiscorrect?()ABothFileReaderandFileInputStreamreaddatabybytesBBothFileReaderandFileInputStreamreaddatabycharactersCFileReaderreadsdatabybytes,whileFileInputStreamreadsdatabycharactersDFileReaderreadsdatabycharacters,whileFileInputStreamreadsdatabybytes第3题WhenreadingthecharacterfileEmployee.dat,whichclassusesthisfileasaparameter?()ABufferedReaderBDataInputStreamCDataOutputStreamDFileInputStream第4题Whichofthefollowingfilereadingandwritingclassessupportsthe"encodingmethod"parameterinitsconstructor?()ABufferedInputStreamBBufferedOutputStreamCInputStreamReaderDFileOutputStream第5题Supposethecontentofthefilec:/a.txtis"abcd".Whatistheresultofexecutingthefollowingcode?()importjava.io.*;publicclassTest{publicstaticvoidmain(Stringargs[])throwsIOException{FileInputStreamfis=newFileInputStream("c:/a.txt");intdata=fis.read();System.out.println(data);fis.close();}}A97BaC-1DCompilationerror第6题Whichofthefollowingfilereadingandwritingclassessupportsthe"encodingmethod"parameterinitsconstructor?()ABufferedInputStreamBBufferedOutputStreamCInputStreamReaderDFileOutputStreamtest第1题Afteracontainerisresized,thecomponentsinthecontainerofwhichlayoutmanagerdonotchangesizewiththecontainer'ssize?()AFlowLayoutBBoxLayoutCBorderLayoutDGridLayout第2题WhichofthefollowingJavacomponentsisacontainercomponent?()AListboxJListBDrop-downlistboxJComboBoxCPanelJPanelDCommandmenuitemJMenuItem第3题Acomponentchangessizehorizontallybutremainsthesamesizevertically.Whichpositionshoulditbeplacedin?()ANorthorSouthpositionofBorderLayoutBEastorWestpositionofBorderLayoutCCenterpositionofBorderLayoutDInGridLayout第4题RegardingJava'seventhandlingmechanism,whichofthefollowingstatementsiscorrect?()AEverycomponentcantriggeranytypeofeventBTheeventhandlingmechanismhasthreeelements:eventsource,listener,andeventhandlinginterfaceCAlistenerdoesnotneedtoimplementallmethodsintheinterface;itcanonlyimplementoneorseveralrequiredmethodsDForeventsgeneratedbyanycomponent,aneventadaptercanbedefinedtohandlethem第5题Whichofthefollowingdescriptionsaboutgraphicaluserinterface()elementsisincorrect?()AThejavax.swingpackagecontainsvariouscomponentsofGUIBThecontainerclass(Container)isasubclassofthecomponentclass(Component)CComponentscanbeaddedtoacontainer,butcontainerscannotbeaddedtoacontainerDThearrangementofcomponentsinacontainerisdeterminedbythelayoutmanagerclasstest第1题WhichofthefollowingstatementsaboutJavathreadsiscorrect?()AAthreadcanonlyrunonceBThestateofathreadismanagedbytheoperatingsystemCAthreadcanbestartedbycallingthestart()methodDTherun()methodofathreadmustbecalledinthemainthread第2题Regardingdaemonthreads(backgroundthreads),whichofthefollowingstatementsisincorrect?()AThreadscreatedinadaemonthreadmustalsobedaemonthreadsBDaemonthreadswillautomaticallyterminateafteralluserthreadsfinishrunningCDaemonthreadsareusuallyusedtoprovideservicesforuserthreadsDThemethodtosetathreadtasadaemonthreadis:t.setDaemon(true);第3题Whichofthefollowingstatementsaboutthreadsisincorrect?()AThethreadbody(dataandexecutioninstructionsequence)canbeimplementedbyinheritingtheThreadclassorimplementingtheRunnableinterfaceBThreadsarescheduledforexecutionbypriority;threadswithhigherprioritywillbeexecutedfirstCThepurposeofmulti-threadsynchronizationistoallowmultiplethreadstoworkconcurrentlyinacoordinatedmannerDWhenmultiplethreadsexecuteconcurrently,therelativeexecutionorderofthreadsisdeterminedbytheorderinwhichthethreadsarestarted第4题WhichofthefollowingstatementsaboutthreadsinJavaisincorrect?()ACallingthejoin()methodmaythrowanInterruptedExceptionBThesleep()methodisastaticmethodoftheThreadclassCCallingthesleep()methodoftheThreadclasscanterminateathreadobjectDThecodeexecutedbyathreadafteritisstartedisplacedinitsrunmethod第5题Iftisathreadobject,whichofthefollowingstatementsisincorrect?()At.start()willstartthreadttoparticipateinthreadschedulingBt.sleep(1)willmakethreadtsleepfor1secondCThet.run()statementwilldirectlyruntherun()methodinsteadofstartingthreadttoparticipateinschedulingDAfterthethreadisstarted,oncetherun()methodfinishesrunning,threadtwillalsodie第6题ThefollowingcodesnippetusestheThreadcl

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论