版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認(rèn)領(lǐng)
文檔簡介
考試綱領(lǐng)第一部分:Java語言基礎(chǔ)第二部分:流程控制第三部分:面向?qū)ο蠓庋b,繼承,多態(tài)第四部分:異常處理第五部分:多線程第六部分:Java垃圾回收機制第七部分:JavaI/O第八部分:Java集合和泛型第九部分:JavaSE實用APIQUESTION1Giventhecodeintheexhibit.Whatistheresult?A.CompilationfailsB.Anexceptionisthrownatruntime.C.AninstanceofForestisserialized.D.AninstanceofForestandaninstanceofTreearebothserialized.Answer:(B)執(zhí)行時期會拋出java.io.NotSerializableExcetpion異常。Tree必須實現(xiàn)Serialized接口;因為Forest實現(xiàn)了序列化,而且引用了Tree,不過Tree沒有實現(xiàn)序列化??!當(dāng)一個實現(xiàn)序列化類在類體里調(diào)用另外一個類時候,那么另外一個類也要實現(xiàn)序列化!假如沒有實現(xiàn),則會報出運行時異常!!假如要實現(xiàn)序列化,他組員變量也必須實現(xiàn)序列化.本題中Tree沒有實現(xiàn)序列化,所以會產(chǎn)生java.io.NotSerializableException運行異常!參考綱領(lǐng):IO操作—對象序列化序列化過程就是對象寫入字節(jié)流和從字節(jié)流中讀取對象。見SCJP.u1.SerializableTestQUESTION2Whichcode,insertedatline14,willallowthisclasstocorrectlyserializedanddesterilized?A.s.defaultReadObject();B.this=s.defaultReadObject();C.y=s.default();x=s.readInt();D.x=s.readInt();y=s.readInt();Answer:(D)在反序列化方法中,從s對象中讀取兩個整數(shù).序列化是寫對象,反序列化是讀對象…參考綱領(lǐng):IO操作—對象序列化QUESTION3Giventheexhibit.Whatistheresult?A.0B.1C.4D.CompilationfailsE.AnexceptionisthrownatruntimeAnswer:(D)產(chǎn)生illegalescapecharacter非法轉(zhuǎn)意符編譯錯誤split()字符切割器本題是想用空格來分割字符串,只能用“”或者“\\s”來分割,“\s”沒有這個轉(zhuǎn)意字符!所以會報編譯錯誤……tab能夠用“\t”;“\”能夠用”\\”表示.Stringsplit方法用來分割字符串,這個方法接收一個正則表示式,依照表示式來分割,“\\s”表示空格,“\s”沒有這個轉(zhuǎn)意字符,所以會產(chǎn)illegalescapecharacter編譯錯誤。參考綱領(lǐng):實用API—Stringsplit()方法和正則表示式QUESTION4Giventheexhibit:ThevariabledfisanobjectoftypeDateFormatthathasbeeninitializedinline11.WhatistheresultifthiscodeisrunonDecember14,?A.ThevalueofSis14-dic-B.ThevalueofSisDec14,C.AnexceptionisthrownatruntimeD.Compilationfailsbecauseofanerrorinline13.Answer:(D)DateFormat用來格式日期,它放在java.text包里,它沒有setLocale方法,Local.Ialy應(yīng)該為Locale.ITALY.代碼語法有問題,,編譯錯誤!參考綱領(lǐng):實用API—java.util包和java.text包QUESTION5ThedoesFileExistmethodtakesanarrayofdirectorynamesrepresentingapathfromtherootfilesystemandafilename.Themethodreturnstrueifthefileexists,falseifdoesnot.Placethecodefragmentsinpositiontocompletethismethod.Answer:()publicstaticbooleandoesFileExist(String[]directories,Stringfilename){Stringpath="";for(Stringdir:directories){path=path+File.separator+dir;}
Filefile=newFile(path,filename);
returnfile.exists();}參考綱領(lǐng):IO操作—FileQUESTION6Given:System.out.printf("Piisapproximately%fandEisapproximately%b",Math.PI,Math.E);Placethevalueswheretheywouldappearintheoutput.Answer:()3.141593True-----------判斷E是否是NULL, NULL是FALSE不然是TRUE.Pi=3.1415926…….E=2.718282……Printf()是C中慣用語法;%f表示浮點數(shù)(小數(shù)點后6位),%b表示boolean,%d表示整數(shù).%e十進制科學(xué)計數(shù)法表示浮點數(shù)%a16進制表示浮點型科學(xué)計數(shù)法整數(shù)部分,以10進制表示指數(shù)%0以8進制表示整數(shù)%x以16進制表示整數(shù)%s字符串個數(shù)輸出%cchar型格式輸出,提供值應(yīng)為整數(shù)型%t輸出日期時間前置????參考綱領(lǐng):實用API—Formatter格式化輸出工具QUESTION7Whencomparingjava.io.BufferedWritertojava.io.FileWriter,whichcapabilityexistasamethodinonlyoneofthetwo?A.closingthestreamB.flushingthestream C.writingtothestream D.markingalocationinthestreamE.writingalineseparatortothestream Answer:(E)只有BufferedWriter具備newLine()方法;Reader才有mark功效。參考綱領(lǐng):I/O操作—BufferWriter和FileWriterQUESTION8Giventheexhibit:Whichtwocodefragments,insertedindependentlyatline3,generatetheoutput4247?(choosetwo)A.Strings="";s.=(s-"123").replace(1,3,"24")-"89";//String中只有”+”表示連接,不過無”-”;產(chǎn)生poerator-cannotbeappliedtojava..lang.String編譯錯誤B.StringBuffers=newStringBuffer("");s.delete(0,3).replace(1,3,"24").delete(4,6);//delete(0,3)表示從0下標(biāo)開始刪除到3下標(biāo)以前C.StringBuffers=newStringBuffer("");s.substring(3,6).delete(1,3).insert(1,"24").Substring()回傳是一個String而不是StringBuffer,String沒有delete方法,產(chǎn)生cannotfindsymbol編譯錯誤D.StringBuilders=newStringBuilder("");s.substring(3,6)delete(1,2).insert(1,"24")錯誤同上E.StringBuilders=newStringBuilder("");s.delete(0,3)replace(1,3,””).delete(2,5).insert(1,"24")Answer:(B,E)String沒有“-”運算符;String不能修改!正確4247S.substring返回是String,String沒有delete()方法S.substring返回是String正確4247參考綱領(lǐng):實用API—String、StringBuffer線程安全適適用于多線程、StringBuilder線程不安全,適合單線程,不過性能高.StringBufferStringBuilder使用方法一樣QUESTION9Answer:(B,D,E)A錯誤,聚合中對象實現(xiàn)了serializable就能被序列化一個類包含另外一個類就是聚合.A描述和對象是否支持序列化沒有直接關(guān)系B正確java是跨平臺,序列化工作也統(tǒng)一交給各個平臺jvm來處理C錯誤,不是volatile而是transient;有這個transient瞬態(tài)關(guān)鍵字話,就不能序列化了!Volatile這個修飾符變量,實現(xiàn)和多線程同時方法類似,不過不是很好用!D正確transient瞬態(tài)對象是不支持序列化E正確,只要子類實現(xiàn)serializable,不用考慮父類有沒有實現(xiàn)serializable參考綱領(lǐng):IO操作—對象序列化QUESTION10Giventheexhibit:Whatistheresult?A.shortLongB.SHORTLONGC.CompilationfailsD.AnexceptionisthrownatruntimeAnswer:(C)向上就近標(biāo)準(zhǔn).第20行g(shù)o(z)將會依序找go(inti),go(longl),go(floatf),go(doubled)或go(Integeri)方法.不過并不會自動向上轉(zhuǎn)型Long然后再呼叫g(shù)o(Longn),這種依次序向上找特征只會發(fā)生在對應(yīng)端基本資料型別情況下,參考綱領(lǐng):面向?qū)ο蟆剌d;實用API—自動封包、拆包QUESTION11Giventheexhibit:*disvalid,non-nullDateobject*dfisavalid,non-nullDateFormatobjectsettothecurrentlocalWhatoutputsthecurrentlocal'scountrynameandtheappropriateversionofD'sdate?A.Localeloc=Locale.getLocal();System.outprintIn(loc.getDisplayCountry()B.Localeloc=Locale.getDefault();System.outprintIn(loc.getDisplayCountry()+""+df.format(d));C.Localeloc=Locale.getLocal();System.outprintIn(loc.getDisplayCountry()+""+df.setDateFormat(d));D.Localeloc=Locale.getDefault();System.outprintIn(loc.getDisplayCountry()+""+df.seDateFormat(d));Answer:(B)ALocale類沒有g(shù)etLocal()方法,編譯錯誤B正確C錯誤Locale類沒有g(shù)etLocal()方法DateFormat沒有setDateFormat()方法,編譯錯誤DDateFormat沒有setDateFormat()方法編譯錯誤參考綱領(lǐng):實用API—java.util包和java.text包QUESTION12Giventheexhibit:Whatistheresult?A.Compilationfails.B.AnexceptionisthrownatruntimeC.Thecodeexecutesandprints"running"D.Thecodeexecutesandprints"runningrunning"E.Thecodeexecutesandprints"runningrunninigrunningAnswer:(E)t.run()調(diào)用main根本程去執(zhí)行2-4行run(),就是一次普通方法調(diào)用;t.start()表示起用thread線程負責(zé)去執(zhí)行2-4行run();把2-4行代碼改為:publicvoidrun(){ StringthreadName=Thread.currentThread().getName();System.out.println(threadName+”:running”);}這么就能夠看出是誰調(diào)用了run()了,顯示以下:main:runningmain:runningThread-o:running參考綱領(lǐng):多線程QUESTION13------------仔細看看Exhibit:Whichtwoarepossibleresults?(choosetwo)A.0,2,4,4,6,8,10,6,B.0,2,4,6,8,10,2,4,C.0,2,4,6,8,10,12,14,D.0,0,2,2,4,4,6,6,8,8,10,10,12,12,14,14,E.0,2,4,6,8,10,12,14,0,2,4,6,8,10,12,14,Answer:(A,C)A第一個線程循環(huán)到第三遍使得x等于4,并執(zhí)行完第8句后掛起(此時current也是4);第二個線程開始執(zhí)行,執(zhí)行完以后第一個線程接著執(zhí)行最終一次循環(huán),打印6C兩個線程依次執(zhí)行參考綱領(lǐng):多線程QUESTION14Giventheexhibit:Whichstatementistrue?A.ThiscodemaythrowanInterruptedException B.ThiscodemaythrowanIllegalStateExcepionC.ThiscodemaythrowaTimeOutExceptionaftertenminutesD.Thiscodewillnotcompileunless"obj.wait()\"isreplacedwith"((Thread)obj).wait()"E.Reversingtheorderofobj.wait()andobj.notify()mayvcausethismethodtocompletenormallyAnswer:(A)首先編譯通不過,第5行:voidwaitForSignal()throwsInterruptedException{…….}第6行: Objectobj=newObject();obj=Thread.currentThread();第7行應(yīng)該是:synchronized(obj);-----在寫wait()和notify()方法時,除了要寫在synchronized區(qū)段,.還需要撰寫InterruptedException異常try-catch.本題就算寫了try-catch,也可能會在執(zhí)行時候產(chǎn)生currentthreadnotownerIllegalMonitorStateException異常.參考綱領(lǐng):多線程—同時處理QUESTION15Giventheexhibit: Whatcanbearesult?A.CompilationfailsB.AnexceptionisthrownatruntimeC.Thecodeexecutesandprints"StartedComplete"D.Thecodeexecutesandprints"StartedComplete0123"E.Thecodeexecutesandprints"Started0123Complete"Answer:(E)Join()方法使得某個線程加入到正在執(zhí)行線程(本題是main線程)中,執(zhí)行完該線程才繼續(xù)執(zhí)行main線程.本程序中第5行由main線程執(zhí)行,6行因為下達了join(),所以mian執(zhí)行將被暫停,等t做完run()方法全部工作之后,才論到main繼續(xù)執(zhí)行未完成工作!參考綱領(lǐng):多線程QUESTION16WhichtwocodefragmentswillexecutethemethoddoStuff()inaseparatethread?(choosetwo)A.newThread(){publicvoidrun(){doStuff();}};B.newThread(){publicvoidstart(){doStuff();}};C.newThread(){publicvoidrun(){doStuff();}}.run();D.newThread(){publicvoidrun(){doStuff();}}.start();E.newThread(newRunable(){publicvoidrun(){doStuff();}}).run();F.newThread(newRunnable(){ publicvoidrun(){doStuff();}}).start();Answer:(D、F)D匿名類別中復(fù)寫run方法,并調(diào)用start()方法開啟線程F利用匿名實現(xiàn)runnable接口中run方法,并調(diào)用start()開啟線程參考綱領(lǐng):多線程QUESTION17Whichthreewillcompileandrunwithoutexception?(choosethree)A.privatesynchronizedobjecto;B.voidgo(){synchronized(){/*codehere*/}}C.publicsynchronizedvoidgo(){/*codehere*/}D.privatesynchronized(this)voidgo(){/*codehere*/}E.voidgo(){synchronized(Object.class){/*codehere*/}}F.voidgo(){synchronized(o){/*codehere*/}}Answer:(C,E,F)A錯誤synchronized不能夠成為屬性/變量修飾符B錯誤synchronized()中括號中要加入欲鎖定物件或類型//synchronized(this)C正確利用synchronized來修飾對象instance方法,鎖定物件將會是this,D錯誤修飾方法時,this不用尤其在synchronized()中指明E正確正當(dāng)classliteralssynchronized//針對某個類同時F正確正當(dāng)instanceblocksynchronized//針對某個對象同時參考綱領(lǐng):多線程—線程同時QUESTION18Exhibit:Whatistheresult?A.ThecodewilldeadlockB.ThecodemayrunwithnooutputC.AnexceptionisthrownatruntimeD.Thecodemayrunwithoutput"06"E.Thecodemayrunwithoutput"2064"F.Thecodemayrunwithoutput"0246" Answer:(F)情況1run方法運行以后運行再調(diào)用getResult();情況2先調(diào)用getResult(),掛起,等候run()方法修改isComplete值線程0,線程1,線程2,線程3,main共有5個線程,中間線程執(zhí)行次序如上面所說,不過最終結(jié)果是mainfor(Computationc:computations)決定,所以結(jié)果總是0246參考綱領(lǐng):多線程QUESTION19Giventheexhibit:Whatistheresult?A.Compilationfails B.AnexceptionisthrownatruntimeC.Thecodeexecutesnormallyandprints"sleep"D.Thecodeexecutesnormally,butnothingisprinted.Answer:(C)執(zhí)行2行時候main被放到Blocked中,過3秒后才會回到Runnablepool中,繼續(xù)執(zhí)行輸出”sleep”參考綱領(lǐng):多線程QUESTION20Whichtwostatementsaretrueabouthas-aandis-arelationships?(choosetwo)A.Inheritancerepresentsanis-arelationshipB.Inheritancerepresentsahas-arelationshipC.Interfacesmustbeusedwhencreatingahas-arelationshipD.Instancevariablescanbeusedwhencreatingahas-arelationshipAnswer:(A,D)Is-a:繼承 classAextendsB{}is-a”是一個”,屬于上下關(guān)系,Has-a:聚合classA{Bb;}has-a“有一個”屬于聚合關(guān)系,在java中用來表示類中組員變量參考綱領(lǐng):面向?qū)ο驫UESTION21Giventheexhibit:Whatcandirectlyaccessandchangethevalueofthevariablename?A.anyclassB.onlytheTargetclassC.anyclassintheCertkillerpackageD.anyclassthatextendsTargetAnswer:(C)要修改name,必須先取得Target對象,Target存取權(quán)限是default,所以同一個包才能訪問。參考綱領(lǐng):面向?qū)ο蟆猵ackage與importQUESTION22Whichthreestatementsaretrue?(choosethree)A.AfinalmethodinclassXcanbeabstractifandonlyifXisabstractB.AprotectedmethodinclassXcanbeoverriddenbyanysubclassofX. C.AprivatestaticmethodcanbecalledonlywithinotherstaticmethodsinclassX.D.Anon-staticpublicfinalmethodinclassXcanbeoverriddeninanysubclassofX.E.ApublicstaticmethodinclassXcanbecalledbyasubclassofXwithoutexplicitlyreferencingtheclassX. F.AmethodwiththesamesignatureasaprivatefinalmethodinclassXcanbeimplementedinasubclassofX. Answer:(B,E,F(xiàn))A錯誤抽象方法必須被實現(xiàn),所以是不能加final修飾符B正確子類能夠正當(dāng)復(fù)寫父類protected權(quán)限方法C錯誤privatestatic方法在X類中方法都能夠調(diào)用,static和non-static都能夠D錯誤final方法不能夠復(fù)寫,除非是private方法.不過這種情況不叫改寫,而是子類有和父類一樣privatefinal方法,兩個方法是各自獨立!!!!E正確不用加上父類別引用,子類就能夠直接調(diào)用父類static方法F正確父類privatestatic方法和子類中同名privatestatic方法是兩個獨立方法,這種情況就不叫改寫,而是各自擁有自己方法!參考綱領(lǐng):面向?qū)ο驫UESTION23PlacetheTypesinoneoftheTypecolumns,andtheRelationshipsintheRelationshipcolumn,todefineappropriatehas-aandis-arelationships.Answer:()Dogis-aAnimal是一類Foresthas-aTree有一個Rectanglehas-aSquare矩形有一個正方形JavaBookis-aProgrammingBook是一個參考綱領(lǐng):面向?qū)ο驫UESTION24ReplacetwooftheModifiersthatappearintheSingleclasstomakethecodecompile.Note:Threemodifierswillnotbeusedandfourmodifiersinthecodewillremainunchanged.Answer:()publicclassSingle{ privatestaticSingleinstance; publicstaticSinglegetInstance(){ if(instance==null)instatnce=create(); returninstance;}protectedSingle(){}因為SingleSub繼承了Single,所以Single結(jié)構(gòu)器必須能夠讓子類訪問到!!!!staticSingleCreate(){ returnnewSingle(); }因為第4行…=create();說明這個方法必須是static方法}參考綱領(lǐng):static組員和繼承時方法權(quán)限控制QUESTION25Exhibit:Whatistheresult?A.Valueis:8B.Compilationfails.C.Valueis:12D.Valueis;-12E.ThecoderunswithnooutputF.Anexceptionisthrownatruntime.Answer:(A)2行,value默認(rèn)是=0;9行實例化一個MultiCale對象,并傳了一個參數(shù)multiplier=2,10行調(diào)用3行方法;方法內(nèi)calculate()又調(diào)用2行,結(jié)果value=0-3;然后super.calculate()調(diào)用父類calculate(),value=-3+7=4;然后6行,value=value*multiplier=4*2=8;然后到11行,輸出valueis:8參考綱領(lǐng):面向?qū)ο驫UESTION26Giventheexhibit:Whichstatementistrue?A.TheclassisfullyencapsulatedB.Thecodedemonstratespolymorphism.C.TheownerNamevariablebreaksencapsulationD.TheCardIDandlimitvariablesbreakpolymorphismE.ThesetCardInformationmethodbreaksencapsulationAnswer:(C)第24行破壞了封裝,應(yīng)該成privateStringownerName;參考綱領(lǐng):面向?qū)ο蟆庋bQUESTION27Giventheexhibit:Whatistheresult?A.peepB.barkC.moveD.Compilationfails.E.AnexceptionisthrownatruntimeAnswer:(E)31行運行時發(fā)生造型異常,運行時錯誤!!30行后Animal實體是dog,31行有轉(zhuǎn)型到cat是不正確(弟兄類之間不能轉(zhuǎn)換)!編譯是沒有錯誤是因為dog和cat有共同父類,參考綱領(lǐng):面向?qū)ο蟆鄳B(tài)QUESTION28------------概念Exhibit:Whattwomusttheprogrammerdotocorrectthecompilationerrors?A.insertacalltothis()intheCarconstructorB.insertacalltothis()intheMeGoconstructorC.insertacalltosuper()intheMeGoconstructorD.insertacalltosuper(vin)intheMeGoconstructorE.changethewheelCountvariableinCARTOPROTECTEDF.CHANGELINE3INTHEMeGoclasstosuper.wheelCount=3;Answer:(D、E)D父類無默認(rèn)結(jié)構(gòu)函數(shù),子類需顯示調(diào)用父類結(jié)構(gòu)函數(shù)利用super(參數(shù))來調(diào)用父類結(jié)構(gòu)函數(shù)EwheelCount為私有變量,子類無法訪問,改成default,publicprotected都能夠,本題改成protected比較適宜2行改為protectedintwheelCount;And2行和3行之間插入super(vin);參考綱領(lǐng):面向?qū)ο驫UESTION29------------多態(tài)Giventheexhibit:polymorphism?(choosethree)A.publicvoidadd(Cc){c.getValue();}B.publicvoidadd(Bb){b.getValue();}C.publicvoidadd(Aa){a.getValue();}D.publicvoidadd(Aa,Bb){a.getValue();}E.publicvoidadd(Cc1,Cc2){c1.getValue();}Answer:(B,C,D)AE只是簡單使用C方法多態(tài)必須存在繼承參考綱領(lǐng):面向?qū)ο蟆鄳B(tài)QUESTION30Giventheexhibit:Whichstatementshouldbeplacedatline14tosuggestthatthevirtualmachineexpendefforttowardrecyclingthememoryusedbytheobjectCertkiller?A.System.gc()B.Runtime.Gc()C.System.freeMemory()D.Runtime.getRuntime().growHeap()E.Runtime.getRuntime().freeMemory()Answer:(A)提議JVM進行資源回收方法:System.gc();Runtime.getRuntime().gc();參考綱領(lǐng):面向?qū)ο蟆厥諜C制QUESTION31Exhibit:Whatistheoutputoftheprogramshownintheexhibit?A.3000.100B.300.3000C.300.300.300.100.100D.300.300.300.300.100Answer:(B)參考綱領(lǐng):Java語言基礎(chǔ)—對象存放QUESTION32AdeveloperiscreatingaclassBook,thatneedstoaccessclassPaper.ThePaperclassisdeployedinaJARnamedmyLib.jar.Whichthree,takenindependently,willallowthedevelopertousethePaperclasswhilecompilingtheBookclass?(choosethree)A.TheJARfileislocatedat$JAVA_HOME/jre/classes/myLib.jarB.TheJARfileislocatedat$/JAVA_HOME/jre/lib/ext/myLib.jar.C.TheJARfileislocatedat/foo/myLib.jarandaclasspathenvironmentvariableissetthatincludes/foo/myLib.jar/Paper,Class.D.TheJARfileislocatedat/foo/myLib.jarandaclasspathenvironmentvariableissetthatincludes/foo/myLib.jar.E.TheJARfileislocatedat/foo/myLib.jarandtheBookclassiscompiledusingjavac-cp/foo/myLib.jar/PaperBookjava.F.TheJARfileislocatedat/foo/myLib.jarandtheBookclassiscompiledusingjavac-d/foo/myLib.jarBookjava.G.TheJARfileislocatedat/foo/myLib.jarandtheBookclassiscompiledusingjavac-classpath/foo/myLib.jarBook.javaAnswer:(B,D,G)Javac-d指定編譯后文件存放位置Javac–cp指定編譯時需要用到類文件位置參考綱領(lǐng):Java語言基礎(chǔ)—Classpath設(shè)定QUESTION33Giventheexhibit:Whichstatementistrueabouttheobjectreferencedbysnoog,smoochandboochimmediatelyafterline23executes?A.NoneoftheseobjectsareeligibleforgarbagecollectionB.OnlytheobjectreferencedbyboochiseligibleforgarbagecollectionC.OnlytheobjectreferencedbysnoogiseligibleforgarbagecolletionD.OnlytheobjectreferencedbysmoochiseligibleforgarbagecollectionE.TheobjectsreferencedbysmoochandboochareeligibleforgarbagecollectionAnswer:(E)孤島參考法,所以三個對象都被回收。參考綱領(lǐng):垃圾回收機制QUESTION34Giventheexhibit:andthecommandlineinvocationjavaCertkiller5abcwhatistheresult?A.abB.bcC.abcD.CompilationfailsE.AnexceptionisthrownatruntimeAnswer:(B)數(shù)組下表從0開始參考綱領(lǐng):Java語言基礎(chǔ)QUESTION35Giventheexhibit:Whatistheresult?A.r,t,tB.r,e,o,C.CompilationfailsD.AnexceptionisthrownatruntimeAnswer:(C)第13行錯誤,check不是boolean類型參考綱領(lǐng):流程控制QUESTION36Giventheexhibit:C.Sperty("rop.custom");D.System.getProperty("rop.custom");依照系統(tǒng)參數(shù)來取出對應(yīng)參數(shù)內(nèi)容E.System.getProperties().getProperty("rop.custom");取得全部系統(tǒng)參數(shù)名稱,再從中取得“prop.custom”值A(chǔ)nswer:(D、E)預(yù)設(shè)系統(tǒng)參數(shù)包含””,“java.version”除預(yù)設(shè)系統(tǒng)參數(shù)還可用java–Dkey1=value1–Dkey2=value2加入一些暫時參數(shù)D、E是正確獲取系統(tǒng)參數(shù)寫法。參考綱領(lǐng):Java語言基礎(chǔ)QUESTION37Givenclassesdefinedintwodifferentfiles:Whatisrequiredatline5inclassCertkillerApptousetheprocessmethodofBitUtils?A.Process(bytes);B.BitUcess(bytes);C.Util.BitUcess(bytes);D.CertkillerAppcannotusemethodsinBitUtilsE.Importutil.BitUtils.*;process(bytes);Answer:(C)參考綱領(lǐng):Java語言基礎(chǔ)QUESTION38Exhibit:Whatistheoutcomeofthecode?A.Compilationfails.B. GobstopperFizzyliftingC. GobstopperScremdiddlyumptiousD. ScrumdiddlyumptiousFizzyliftingE. ScrumiddlyumptiousScrumdiddlyumptiousAnswer:(B)參考綱領(lǐng):Java語言基礎(chǔ)—存放機制QUESTION39GivenclassesdefinedintwodifferentfilesWhatisrequiredatline5inclassCertkillerApplicationtousetheprocessmethodofBitUtils?A.PROCESS(BYTES);B.BitUcess(bytes);C.App.BitUcess(bytes)D.Util.BitUcess(bytes)E.Importutil.Bitutils.*;process(bytes);F.CertkillerApplicationcannotusetheprocessmethodinBitUtils.Answer:(F)Private是私有方法,不能被Certkiller調(diào)用參考綱領(lǐng):Java語言基礎(chǔ)—存取修飾符QUESTION40Theimagerepresentsacompletepackagestructureforasetofclasses:"com"isthebeginningofthefully-qualifiedpackagenameforallclasses.Givethispackagestructure,insertthecodeneededtomaketheCarclasscompileandrunsuccessfully.Allthreeplaceholdsmustbefilled.Iffewerthanthreestatementareneeded,usethe"http://blank"options.Answer:()packagecom.bar;importcom.foo.bar.blatz.*;importcom.foo.bar.*
;publicclassCar{ Bookbook
; Dogdog
;}參考綱領(lǐng):Java語言基礎(chǔ)—包QUESTION41Giventheexhibit:Whatistheresultwhenthiscodeexecuted?A.1B.3C.123D.321E.ThecoderunswithnooutputAnswer:(C)子類先調(diào)用父類結(jié)構(gòu)函數(shù),在調(diào)用自己結(jié)構(gòu)函數(shù);參考綱領(lǐng):Java語言基礎(chǔ)—繼承和結(jié)構(gòu)函數(shù)QUESTION42PlacethecodefragmentsinpositiontocompletetheDisplayableinterface.Answer:()interfaceDisplayableextendsReloadable{ publicvoiddisplay();}參考綱領(lǐng):面向?qū)ο蟆涌诶^承QUESTION43Giventheexhibit:Whichcode,insertedatline14,allowstheSpriteclasstocompile?A.Directiond=NORTHB.Certkiller.Directiond=NORTHC.Directiond=Direction.NORTHD.Certkiller.Directiond=CertkillerDirection.NORTHAnswer:(D)Enum枚舉類一個enum就像一個class,所以參考內(nèi)部類使用方法選擇D參考綱領(lǐng):面向?qū)ο蟆猠num類型QUESTION44Exhibit:Whichthreestatementsaretrue?(Choosethree)A.CompilationfailsB.Thecodecompilesandtheoutputis2。C.Iflines16,17and18wereremoved,compilationwouldfail.D.Iflines24,25,and26wereremoved,compilationwouldfail.E.Iflines16,17and18wereremoved,thecodewouldcompileandtheoutputwouldbe2.F.Ifline24,25and26wereremoved,thecodewouldcompileandtheoutputwouldbe1.Answer:(B,E,F(xiàn))一個內(nèi)部類ClassA,一個方法內(nèi)部類ClassA參考綱領(lǐng):面向?qū)ο驫UESTION45AddmethodstotheBetaclasstomakeitcompilecorrectly.Answer:()publicclassBeataextendsAlpha{publicvoidbar(intx){}publicintbar(Stringx){return1;}publicvoidbar(intx,inty){}}privatevoidbar(intx){}錯誤覆寫時存取權(quán)限不能夠小于原方法publicvoidbar(intx){}正確覆寫publicintbar(Stringx){returnl;}正確覆載publicAlphabar(intx){intx}{} 錯誤覆寫時傳回值能夠與原來方法返回值相等或者是子類別,本例中原來返回是void,這么子類別中只能用void來修飾bar()方法。publicvoidbar(intx,inty){}正確覆載publicintbar(intx){returnx;}錯誤覆載參考綱領(lǐng):面向?qū)ο蟆矊懞透草dQUESTION461.publicclassTest{2. intx=12;3. publicvoidmethod(intx){4. x+=x;5. System.out.println(x);6. }7.}And:22. Testt=newTest();23. t.method(5);Whatistheoutputfromline5oftheCertkillerclass?A.5B.10C.12D.17E.24Answer:(B)參考綱領(lǐng):語言基礎(chǔ)QUESTION47Giventheexhibit:Whichtwomethods,insertedindividually,correctlycompletetheCertkiller3class?(choosetwo)A.publicvoidfoo(){}B.publicintfoo(){return3:}C.publicCertKiller2foo(){returnthis;}D.publicCertkiller1foo(){returnthis;}Answer:(C,D)返回值要么和原來相同要么就是直系子類,原方法返回是Certkiller1類,所以返回Certkiller2也是正確。參考綱領(lǐng):面向?qū)ο蟆矊懞透草dQUESTION48Exhibit:Whatistheresult?A.snootchy420thirdsecondfirstB.snootchy420firstsecondthirdC.firstsecondthirdsnootchy420D.thirdsecondfirstsnootchy420E.thirdsfirstsecondsnootchy420F.firstsecondfirstthirdsnootchy420Answer:(D)參考綱領(lǐng):面向?qū)ο蟆草dQUESTION49Giventheexhibit:Whatistheresult?A.123B.Compiltionfailsbecauseofanerrorinline12.C.Compilationfailsbecauseofanerrorinline13D.Compilationfailsbecauseofanerrorinline14.E.AClassCastExceptionisthrownatruntimeAnswer:(A)參考綱領(lǐng):流程控制QUESTION50AJavaBeancomponenthasthefollowingfield:11.privateBooleanenabled;WhichtwopairsofmethoddeclarationsfollowtheJavaBeanstandardforaccessingthisfields?(choosetwo)A. publicvoidsetEnabled(Booleanenabled)publicBooleangetEnabled()B. publicvoidsetEnabled(Booleanenabled)publicvoidisEnabled()C. publicvoidsetEnabled(Booleanenabled)publicBooleanisEnabled()D. publicBooleansetEnabled(Booleanenabled)publicvoidgetEnabled()Answer:(A,C)參考綱領(lǐng):語言基礎(chǔ)—JavaBeanQUESTION51Giventheexhibit:Whichtwostatementsaretrue?(choosetwo)A.Certkiller.beta()isavalidinvocationofbeta()B.Certkiller.alpha()isavalidinvocationofalpha()C.Methodbeta()candirectlycallmethodalpha()D.Methodalpha()candirectlycallmethodbeta()Answer:(B,C)alpha()是靜態(tài)方法,能夠使用Certkiller.alpha()直接調(diào)用。non-static方法能夠直接調(diào)用satic或者non-static方法參考綱領(lǐng):面向?qū)ο驫UESTION52Giventheexhibit:WhichtwoclassesusetheShapeclasscorrectly?(choosetwo)A.publicclassCircleimplementsShape{privateintradius;}B.publicabstractclassCircleextendsShape{privateintradius;}C.publicclassCircleextendShape{privateintradius;publicvoiddraw();}D.publicabstractclassCircleimplementsShape{privateintradius;publicvoiddraw();}E.publicclassCircleextendsShape{privateintradius;publicvoiddraw(){/*CODEHERE*/}}F.publicABSTRACTclassCircleimplementsShape{privateintradius;publicvoiddraw(){/*codehere*/}}Answer:(B,E)抽象類是被繼承,抽象方法是要被改寫,假如某個類繼承了一個抽象類而沒有實現(xiàn)父類中抽象方法,那么
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 公共交通乘客服務(wù)管理制度
- 2026年企業(yè)內(nèi)部管理能力測試題目
- 2026年商務(wù)英語中級認(rèn)證同步自測與提升練習(xí)題
- 2026年歷史學(xué)科知識重點試題及答案解析
- 2026年汽車行業(yè)候選人汽車安全性能測試分析
- 2026年法律知識測試題合同法與知識產(chǎn)權(quán)法要點題庫
- 2026年海報制作服務(wù)合同(高清·噴繪版)
- 2026年工程竣工驗收協(xié)議(全面·達標(biāo)版)
- 隱睪癥的術(shù)后護理
- 新生兒常見疾病預(yù)防與護理
- 2026貴州貴陽市安航機械制造有限公司招聘8人考試重點試題及答案解析
- 2026重慶高新開發(fā)建設(shè)投資集團招聘3人備考考試試題及答案解析
- 2025年加油站培訓(xùn)數(shù)質(zhì)量標(biāo)準(zhǔn)課件
- 《電梯基本結(jié)構(gòu)》課件
- 兒童發(fā)育遲緩的早期干預(yù)與教育策略
- 刀模管理制度
- 揮發(fā)性有機物(VOCs)執(zhí)法監(jiān)測能力建設(shè)項目可行性實施方案
- 工程施工月報表
- 鍋爐外部檢驗報告
- GB/T 3098.6-2023緊固件機械性能不銹鋼螺栓、螺釘和螺柱
- 音標(biāo)拼讀練習(xí)(彩色版)
評論
0/150
提交評論