版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
QUESTION61GIVENTHEEXHIBIT:Whichstatementistrue?A.Alloftheassertstatementsareusedappropriately.B.Onlytheassertstatementonline31isusedappropriatelyC.Theassertstatementsonlines29and31areusedappropriatelyD.Theassertstatementsonlines26and29areusedappropriatelyE.Theassertstatementsonlines29and33areusedappropriatelyF.Theassertstatementsonlines29,31and33areusedappropriatelyG.Theassertstatementsonlines26,29and31areusedappropriately斷言應(yīng)當用在“你認為”你的程序不也許產(chǎn)生錯誤的地方,并且有沒有啟用斷言,都不會影響程序的正常運營。斷言使用限制:不要在public方法中,用斷言來檢查參數(shù)的對的性;不要讓斷言語句去解決一些程序必須的流程。因素:1.public方法會被別人調(diào)用,你不能保證他一定啟用斷言;假如沒有啟用,那么用斷言來做參數(shù)的檢查也就沒故意義了。所以不要用斷言來檢查參數(shù),公共方法的參數(shù)一定要用代碼執(zhí)行檢查; 2.假如用斷言來控制程序執(zhí)行流程,假如沒有啟用斷言,那么程序就不能對的執(zhí)行下去。此外,斷言語句不可以有任何邊界效應(yīng),不要使用斷言語句去修改變量和改變方法的返回值,假如這樣當啟動斷言和不啟動斷言執(zhí)行的結(jié)果會截然不同。斷言的使用時機:檢查流程的不變性:在if-elseswitch-case的預期結(jié)果之外可以加上斷言做額外的檢查。內(nèi)部執(zhí)行的不變性:if(true){return;}assertfalse;檢查私有方法的參數(shù),結(jié)果等程序運營中的一致性斷言語句不是永遠會執(zhí)行,可以屏蔽也可以啟用
javac–source1.4*.java需要java–ea啟用assert;當判斷條件為FALSE時就拋犯錯誤。Answer:(C)26行不合適:不要對public方法的參數(shù)斷言29合適:程序員在程序中最不大也許到達的地方斷言
31合適:斷言private方法的參數(shù)
33行不合適:啟用和不啟用斷言會產(chǎn)生不同的程序執(zhí)行序
參考大綱:異常解決—斷言和AssertionErrorQUESTION62GIVENTHEEXHIBIT:Whatistheresult?A. nullB. zeroC. someD. CompilationfailsE. AnexceptionisthrownatruntimeAnswer:(D)13行會報錯,應(yīng)在15行使用elseif參考大綱:流程控制QUESTION63Giventheexhibit:Whatistheresult?A.testB.ExceptionC.CompilationfailsD.NullPointerExceptionAnswer:(C)18行犯錯,應(yīng)當先catch子異常,再catchException;13行把args賦null,14行會報NullPointerException假如沒有第13行運營時14行會報ArrayIndexOutOfBoundsException異常。參考大綱:異常解決QUESTION64Giventheexhibit:Whatistheresult?A.CompilationfailsB.aAaAaAaAAaaAaAC.AAaaAaAaAaaAaAD.AaAAAaaaAaAaAaE.aAaAaAaAaAAAaaF.AnexceptionisthrownatruntimeAnswer:(C)第10行將對strings這個集合做自然排序(ASCII小到大,一個一個比較)Collections.sort(Listlist)對list進行排序,對set不能排序!List里可以放對象,所以當list里面存放的是對象的時候就不能用Collections.sort(Listlist)去排序了。由于JVM不知道用什么規(guī)則去排序??!只有把對象類實現(xiàn)Comparable接口,然后改寫compareTo()參考大綱:集合QUESTION65Giventheexhibit:Whatistheresult?A.0B.1C.2D.3E.4F.Compilationfails.G.AnexceptionisthrownatruntimeAnswer:(D)Set中存放的元素是無序不反復的。假如你想Set里Add一個元素,一方面他會去調(diào)用equals方法,判斷set中是否有該元素,假如有則不更改set的值并返回false,假如沒有,則把元素添加進去,并返回true。Ws1ws2是自定義的類,ws1和ws2equals不相等;String的equals方法已經(jīng)改寫,s1和s2相等;比較兩個對象是否相同,先比較hashcode,假如相同,在用equals方法比較.假如都相同則兩個對象就認為是相同的.Hashcode是把對象的內(nèi)存地址通過運算得來的.基本數(shù)據(jù)類型和基本數(shù)據(jù)類型的包裝類尚有String類都已經(jīng)覆蓋了hashcode(),equals(),所以這些對象的值只要同樣就認為對象同樣.參考大綱:集合QUESTION66Givenapre-genericsimplementationofamethod:Whichthreechangesmustbemadetothemethodsumtousegenerics?(choosethree)A.removeline14B.replaceline14with"inti=iter.next();"C.replaceline13with"for(inti:intList){"D.replaceline13with"for(Iteratoriter:intList)"E.replacethemethoddeclarationwith"sum(List<int>intList)"F.replacethemethoddeclarationwith"sum(List<Integer>intList)"Answer:(A,C,F)publicstaticintsum(List<Integer>intList){intsum=0;for(inti:intList){ sum+=i;}returnsum;}參考大綱:集合和泛型Whatistheresult?A.Compilationfailsduetoanerrorinline23.B.Compilationfailsduetoanerrorinline29.C.AClassCastExceptationoccursinline29.D.AClassCastExceptationoccursinline31.E.Thevalueofallfourobjectprintsinnaturalorder.Answer:(C)Arrays.sort(Object[]a)方法中,a的每一個元素都必須是互相可以比較的(調(diào)用pareTo(Objecto2))。否則會報ClassCastException的異常。參考大綱:泛型QUESTION68PlacethecodeintopositiontocreateaclassthatmapsfromStringstoIntegervalues.Theresultofexecutionmustbe[one].Someoptionsmaybeusedmorethanonce.Answer:()publicclassNumberNames{ privateHashMap<String,Integer>map=newHashMap<String,Integer>(); publicvoidput(Stringname,Integervalue){ map.put(name,value); } publicSet<String>getNames(){ Returnmap.keySet(); }}QUESTION69Placearesultontoeachmethodcalltoindicatewhatwouldhappenifthemethodcallwereinsertedatline9.Note:Resultscanbeusedmorethanonce.Answer:()MethodResultm1(listA)Compilesandrunswithouterror泛型規(guī)范沒問題m2(listA)Compilesandrunswithouterror泛型規(guī)范沒問題m1(listB)CompilesandrunswithouterrorB是A的子類,泛型規(guī)范沒問題m2(listB)Doesnotcompilem1(listO)Doesnotcompilem2(listO)DoesnotcompileQUESTION70Giventheexhibit:Whatistheresult?A.apple:appleB.carrot:appleC.apple:bananaD.banana:appleE.carrot:carrotF.carrot:bananaAnswer:(C)PriorityQueue優(yōu)先級隊列:預設(shè)是自然排序,因此pq內(nèi)的元素順序?qū)⑹莂pple->banana->carrotpoll()取第一個元素,取完之后刪除,peek取第一個元素,并不刪除元素QUESTION71Given:AprogrammerisdevelopingaclassKey,thatwillbeusedasakeyinastandardjava.util.HashMap.Whichtwomethodsshouldbeoverriddentoassurethatkeyworkscorrectlyasakey?(choosetwo)A.publicinthashCode()B.publicBooleanequals(Keyk)C.publicintcompareTo(Objecto)D.publicBooleanequals(Objecto)Answer:(A,D)HashMap中的key不能反復,因此必須實現(xiàn)hashCode和equals方法QUESTION72---Giventheexhibit:Whichtwo,insertedatline2willallowthecodetocompile?(ChooseTwo)A.publicclassMinMax<?>{B.publicclassMinMax<?extendsNumber>{C.publicclassMinMax<NextendsObject>{D.publicclassMinMax<NextendsNumber>{E.publicclassMinMax<?extendsObject>{F.publicclassMinMax<NextendsInteger>{Answer:(D,F)N是泛型類別變量,它相稱于一個類型。A 類聲明是不能用?這個萬用字符。B 同上C Object沒有doubleValue()方法。D OK.E 同A。F OK.QUESTION73Giventheexhibit:enumExample{ONE,TWO,THREE}Whichstatementistrue?A.Theexpressions(ONE==ONE)andONE.equals(ONE)arebothguaranteedtobetrue.B.Theexpression(ONE<TWO)isguaranteedtobetrueandONE.compareTo(TWO)isguaranteedtobelessthanone.C.TheExamplevaluescannotbeusedinarawjava.util.HashMap.;instead,theprogrammermustuseajava.util.EnumMap.D.TheExamplevaluescanbeusedinajava.util.SortedSet,butthesetwillNOTbesortedbecauseenumeratedTypedoNOTIMPLEMENTjava.lang.Comparable.Answer:(A)A對的B不能保證C錯誤枚舉類型的元素是可以用在HASHMAP里的HashMap<Integer,Example>h=newHashMap<Integer,Example>;h.put(1,Example.ONE);D錯誤,枚舉類型的元素值是可以放入SortedSet里的例如TreeSet.把枚舉類型的元素轉(zhuǎn)成字符串在放入其中,字符串就已經(jīng)實現(xiàn)comparable接口??梢宰匀慌判?。SortedSet<Example>s=newTreeSet<Example>();s.add(Example.TWO);s.add(Example.ONE);System.out.println(s);打印出結(jié)果[ONE,TWO]QUESTION74Giventheexhibit:WhichlineofcodemarkstheearliestpointthatanobjectreferencedbyintObjbecomesacandidateforgarbagecollection?A.Line16B.Line17C.Line18D.Line19E.TheobjectisNOTacandidateforgarbagecollection.Answer:(D)intObj一直會被numbers引用,直到19行之后QUESTION75Given:Andthecommandlineinvocation:javaYippee2abcWhatistheresult?A.abB.bcC.abcD.Compilationfails.E.Anexceptionisthrownatruntime.Answer:(B)QUESTION76Aclassgames.cards.PokeriscorrectlydefinedinthejarfilePoker.jar.AuserwantstoexecutethemainmethodofPokeronaUNIXsystemusingthecommand:Javagames.cards.PokerWhatallowstheusertodothis?A.putPoker.jarindirectory/stuff/java,andsettheCLASSPATHtoinclude/stuff/javaB.putPoker.jarindirectory/stuff/java,andsettheCLASSPATHtoinclude/stuff/java/*.jarC.putPoker.jarindirectory/stuff/java,andsettheCLASSPATHtoinclude/stuff/java/Poker.jarD.putPoker.jarindirectory/stuff/java/games/cards,andsettheCLASSPATHtoinclude/stuff/javaE.putPoker.jarindirectory/stuff/java/games/cards,andsettheCLASSPATHtoinclude/stuff/java/*.jarF.putPoker.jarindirectory/stuff/java/games/cards,andsettheCLASSPATHtoinclude/stuff/java/Poker.jarAnswer:(C)classpath中須明確寫明poker.jar,不能用*.jarQUESTION77Whichthreecodefragments,addedindividuallyatline29,producetheoutput100?(Choosethree.)A.n=100;B.i.setX(100);C.o.getY().setX(100);D.i=newInner();i.setX(100);E.0.setY(i);i=newInner();i.setX(100);F.i=newInner();i.setX(100);o.setY(i);Answer:(B,C,F)根據(jù)內(nèi)存關(guān)系可知QUESTION78GivenaclassRepetition:AndgivenanotherclassDemo:Whichcodeshouldbeinsertedatline1ofDemo.javatocompileandrunDemotoprint"pizzapizza"A.importutils.*;B.staticimportutils.*;C.importutils.Repetition.*;D.staticimportutils.Repetition.*;E.importutils.Repetition.twice();F.importstaticutils.Repetition.twice;G.staticimportutils.Repetition.twice;Answer:(F)靜態(tài)import引入靜態(tài)方法.importstaticutils..Repetition*;或者importstaticutils.Repetition.twice;A 正常的導入類,Demo的第5行要new實例才干帶用twice方法.B staticimport順序顛倒,并且要加上class名C 正常的導入,類名后面不能跟*D 順序顛倒E 正常的導入,只能導入包下的類,不能導入類里的方法.G 順序顛倒QUESTION79Given:Andtheinvocation:Whatistheresult?A.Anexceptionisthrownatruntime.B."Stringisempty"isprintedtooutput.C.Compilationfailsbecauseofanerrorinline12.D."Stringisnotempty"isprintedtooutput.Answer:(A)A空指針異常------------------“|”是非短路邏輯運算符QUESTION80Exhibit:Giventhefully-qualifiedclassnames:com.foo.bar.Dogcom.foo.bar.blatz.Bookcom.bar.Carcom.bar.blatz.SunWhichgraphrepresentsthecorrectdirectorystructureforaJARfilefromwhichthoseclassescanbeusedbythecompilerandJVM?A.JarAB.JarBC.JarCD.JarDE.JarEAnswer:(A)QUESTION81Given:andtwoseparatecommandlineinvocations:javaYippeejavaYippee1234Whatistheresult?Nooutputisproduced.123B. Nooutputisproduced.234C. Nooutputisproduced.1234D. Anexceptionisthrownatruntime.123E. Anexceptionisthrownatruntime.234F. Anexceptionisthrownatruntime.1234Answer:(B)QUESTION82Given:Whatistheresult?A.CompilationfailsB.AnexceptionisthrownatruntimeC.doStuffx=6mainx=6D.doStuffx=5mainx=5E.doStuffx=5mainx=6F.doStuffx=6mainx=5Answer:(D)第10行參數(shù)x是值傳遞,不會改變main中x的值。QUESTION83Given:WhenthedoSomethingmethodiscalled,afterwhichlinedoestheObjectcreatedinline5becomeavailableforgarbagecollection?A.Line5B.Line6C.Line7D.Line8E.Line9F.Line10Answer:(D)棧內(nèi)存用來存放基本類型的變量和對象的引用變量(對象的地址)堆內(nèi)存用來存放由new創(chuàng)建的對象和數(shù)組QUESTION84Given:Whatistheresult?A. ExceptionB. A,B,ExceptionC. Compilationfailsbecauseofanerrorinline20.D. Compilationfailsbecauseofanerrorinline14.E. ANullPointerExceptionisthrownatruntime.Answer:(D)改寫的規(guī)定,子類拋出的異常要比父類的異常要小.本題中父類沒有異常,子類也不能有異常.QUESTION85Given:Whatistheresult?A.harrierB.shepherdC.retrieverD.CompilationfailsE.retrieverharrierF.Anexceptionisthrownatruntime.Answer:(D)18行,casedefault:語法錯誤,應(yīng)改成default:QUESTION86Given:Whatistheresult?A. A,B,CB. B,C,AC. CompilationfailsD. ThecoderunswithnooutputE. AnexceptionisthrownatruntimeAnswer:(B)LinkedList有順序性,QUESTION87GivenWhatistheresult?A.endB.CompilationfailsC.exceptionendD.exceptiontestendE.AThrowableisthrownbymainF.AnExceptionisthrownbymainAnswer:(E)16行拋出Error,沒有捕獲。Throwable,Error和Exception都是他的子類QUESTION88Given:Whichthree,willmakecodeon37executeA.Theinstancegetsgarbagecollected.B.Thecodeonline33throwsanexception.C.Thecodeonline35throwsanexception.D.Thecodeonline31throwsanexception.E.Thecodeonline33executessuccessfully.Answer:(B,C,E)QUESTION89Given:Whatistheresult?A.CompilationfailsB.piisbiggerthan3.C.Anexceptionoccursatruntime.D.piisbiggerthan3.Haveaniceday.E.piisnotbiggerthan3.Haveaniceday.Answer:(A)18行finally是配合try使用的.QUESTION90Given:Whichcode,insertedatline16willcauseajava.lang.ClassCastException?A.Alphaa=x;B.Foof=(Delta)x;C.Foof=(Alpha)x;D.Betab=(Beta)(Alpha)x;Answer:(B)轉(zhuǎn)到子類別拋異常。.QUESTION91Givenamethodthatmustensurethatitsparameterisnotnull:What,insertedatline12,istheappropriatewaytohandleanullvalue?A.assertvalue==null;B.assertvalue!=null,"valueisnull";C.if(value==null){thrownewAssertionException("valueisnull");}D.if(value==null){thrownewIllegalArgumentException("valueisnull");}Answer:(D)A 不要用斷言對公共方法的參數(shù)進行判斷B 同上C 沒有AssertionException這個類;AssertionError繼承自Error,handleerror是沒故意義的D OK拋出參數(shù)錯誤的異常.QUESTION92PlacethecorrectCodeintheCodeSampletoachievetheexpectedresults.Expectedresults:Output:12481632CodeSampleAnswer:()for(intx:y){QUESTION93Given:WhichtwowillproduceanAssertionError?(Choosetwo.)A.javatestB.java-eatestC.javatestfile1D.java-eatestfile1E.java-eatestfile1file2F.java–ea:testtestfile1Answer:(B,E)QUESTION94Given:WhichstatementistrueifaResourceExceptionisthrownonline86?A.Line92willnotexecute.B.Theconnectionwillnotberetrievedinline85.C.Theresourceconnectionwillnotbeclosedonline88. D.Theenclosingmethodwillthrowanexceptiontoitscaller.Answer:(C)QUESTION95AssumingthattheserializeBanana()andthedeserializeBanana()methodswillcorrectlyuseJavaserializationandgiven:Whatistheresult?A.restore400B.restore403C.restore453D.Compilationfails.E.Anexceptionisthrownatruntime.Answer:(C)QUESTION96Given:Whatistheresult?A.CompilationfailsB.Piisapproximately3.C.Piisapproximately3.141593.D.Anexceptionisthrownatruntime.Answer:(D)%d打印一個整數(shù),規(guī)定接受一個整數(shù)拋IllegalFormatConversionExceptionQUESTION97Given:Whatistheresult?A.intLongB.ShortLongC.CompilationfailsD.Anexceptionisthrownatruntime.Answer:(A)QUESTION98Chaintheseconstructorstocreateobjectstoreadfromafilenamed"in"andtowritetoafilenamed"out".Answer:()newBufferedReader(newFileReader(“in”));newPrintWriter(newBufferedWriter(newFileWriter(“out”)));QUESTION99PlacethecodefragmentsintopositiontouseaBufferedReadertoreadinanentiretextfile.Answer:()classPrintFile{ publicstaticvoidmain(String[]args){ BufferedReaderbuffReader=null; //morecodeheretoinitializebuffReader try{ Stringtemp; while((temp=buffReader.readLine())!=null){ System.out.println(temp); } }catch(IOExceptione){ e.printStackTrace(); } }}QUESTION100Giventhismethodinaclass:Whichstatementistrue?A.ThiscodeisNOTthread-safe.B.TheprogrammercanreplaceStringBufferwithStringBuilderwithnootherchanges.C.Thiscodewillperformpoorly.Forbetterperformance,thecodeshouldberewritten:return"<"++">";D.ThiscodewillperformwellandconvertingthecodetouseStringBuilderwillnotenhancetheperformance.Answer:(B)QUESTION101Given:WhatcreatestheappropriateDateFormatobjectandaddsadaytotheDateobject?A. 35.Dateformatdf=Dateformat.getDateFormat();42.d.setTime((60*60*24)+d.getTime());B. 35.Dateformatdf=Dateformat.getDateInstance();42.d.setTime((1000*60*60*24)+d.getTime());C. 35.Dateformatdf=Dateformat.getDateFormat();42.d.setLocalTime((1000*60*60*24)+d.getLocalTime());D. 35.Dateformatdf=Dateformat.getDateInstance();42.d.setLocalTime((60*60*24)+d.getLocalTime());Answer:(B)轉(zhuǎn)換成求加1天以后改日期的毫秒數(shù),再調(diào)用setTime()設(shè)立時間QUESTION102Given:WhichtwostatementsaretrueabouttheresultifthelocaleisLocale.US?(Choosetwo.)A.Thevalueofbis2.B.Thevalueofais3.14.C.Thevalueofbis2.00.D.Thevalueofais3.141.E.Thevalueofais3.1415.F.Thevalueofais3.1416.G.Thevalueofbis2.0000.Answer:(C,F)QUESTION103Placethecorrectdescriptionofthecompileroutputonthecodefragmenttobeinsertedatline4and5.Thesamecompileroutputmaybeusedmorethanonce.Answer:()QUESTION104Given:Whichthreewillcompilesuccessfully?(Choosethree.)A.Objecto=Old.get0(newLinkedList());B.Objecto=Old.get0(newLinkedList<?>());C.Strings=Old.get0(newLinkedList<String>());D.Objecto=Old.get0(newLinkedList<Object>());E.Strings=(String)Old.get0(newLinkedList<String>());Answer:(A,D,E)B錯誤<?>不應(yīng)出現(xiàn)在這里C錯誤get0()方法的回傳值是Object,因此不可賦值給StringQUESTION105Exhibit:Whichstatementistrueaboutthesetvariableonline12?A.Thesetvariablecontainsallsixelementsfromthecollcollection,andtheorderisguaranteedtobepreserved.B.Thesetvariablecontainsonlythreeelementsfromthecollcollection,andtheorderisguaranteedtobepreserved.C.Thesetvariablecontainsallsixelementsfromthecollcollection,buttheorderisNOTguaranteedtobepreserved.D.Thesetvariablecontainsonlythreeelementsfromthecollcollection,buttheorderisNOTguaranteedtobepreserved.Answer:(D)Set中元素是不能反復,沒有順序的QUESTION106Given:WhatistheappropriateddefinitionofthehashCodemethodinclassPerson?A.returnsuper.hashCode();B.returnname.hashCode()+age*7;C.returnname.hashCode()+comment.hashCode()/2;D.returnname.hashCode()+comment.hashCode()/2-age*3;Answer:(B)兩個equals的對象,hashCode()應(yīng)當相等,equals中是判斷age和name相等,所以hashCode也用age和name計算,A,C,D也許導致兩個相等的對象,hashCode不相等QUESTION107Given:Whichstatementistrue?A.TheequalsmethoddoesNOTproperlyoverridetheObject.equalsmethod.B.Compilationfailsbecausetheprivateattributecannotbeaccessedinline5.C.Toworkcorrectlywithhash-baseddatastructures,thisclassmustalsoimplementthehashCodemethod.D.WhenaddingPersonobjectstojava.util.Setcollection,theequalsmethodinline4willpreventduplicates.Answer:(A)QUESTION108Given:Whichcode,insertedatline4,guaranteesthatthisprogramwilloutput[1,2]?A.Setset=newTreeSet();B.Setset=newHashSet();C.Setset=newSortedSet();D.Listset=newSortedList();E.Setset=newLinkedHashSet();Answer:(A)TreeSet可自動排序,SortedSet是接口,不能實例化QUESTION109Given:What,insertedatline39,willsortthekeysinthepropsHashMap?A.Array.sort(s);B.s=newTreeSet(s);C.Collections.sort(s);D.s=newSortedSet(s);Answer:(B)QUESTION110Placecodeintotheclasssothatitcompilesandgeneratestheoutputanswer=42.Note:Codeoptionsmaybeusedmorethanonce.Answer:()publicclassGen<T>{ privateTobject; publicGen(Tobject){ this.object=object;}publicTgetObject(){ returnobject;}…}QUESTION111----------------???第一選項解釋Given:PlacetheCompilationResultsoneachcodestatementtoindicatewhetherornotthatcodewillcompileifinsertedintothetakeList()method.Answer:()List<String>StrList=newArrayList<String>();List<Integer>IntList=newArrayList<Integer>();List<?extendsObject>list;//該類型的泛型之能接受對象賦值,不能直接對該對象進行add操作.//list.add(newObject());list=StrList;list=IntList;QUESTION112WhichtwocodefragmentswillexecutethemethoddoStuff()inaseparatethread?(Choosetwo.)A. newThread(){publicvoidrun(){doStuff();}};B. newThread(){publicvoidstart(){doStuff();}};C. newThread(){publicvoidstart(){doStuff();}}.run();D. newThread(){publicvoidrun(){doStuff();}}.start();E. newThread(newrunnable(){publicvoidrun(){doStuff();}}).run();F. newThread(newrunnable(){publicvoidrun(){doStuff();}}).start();Answer:(D,F)D匿名類別中復寫run方法,并調(diào)用start()方法啟動線程F運用匿名實現(xiàn)runnable接口中的run方法,并調(diào)用start()啟動線程QUESTION113Given:Whichtocanberesults?(Choosetwo.)A. java.lang.RuntimeException:ProblemB. run.java.lang.RuntimeException:ProblemC. Endofmethod.java.lang.RuntimeException:ProblemD. Endofmethod.run.java.lang.RuntimeException:ProblemE. run.java.lang.RuntimeException:ProblemEndofmethodAnswer:(D、E)在t中拋出RuntimeException,不干擾主線程的執(zhí)行;QUESTION114----Given:Whichthreechangesshouldbemadetoadaptthisclasstobeusedsafelybymultiplethreads?(Choosethree.)A.declarereset()usingthesynchronizedkeywordB.declaregetName()usingthesynchronizedkeywordC.declaregetCount()usingthesynchronizedkeywordD.declaretheconstructorusingthesynchronizedkeywordE.declareincrement()usingthesynchronizedkeywordAnswer:(A,C,E)D選項錯誤,由于構(gòu)造方法不能用synchronized修飾name是final變量不會有多線程上維護的問題QUESTION115Given:Whichstatementistrue?A.CompilationfailsB.Anexceptionisthrownatruntime.C.Synchronizingtherun()methodwouldmaketheclassthread-safe.D.Thedatainvariable"x"areprotectedfromconcurrentaccessproblems.E.DeclaringthedoThings()methodasstaticwouldmaketheclassthread-safe.F.WrappingthestatementswithindoThings()i
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 關(guān)于開學典禮演講稿匯編10篇
- 不一樣的春節(jié)演講稿10篇
- 肯德基寒假實習報告4篇
- 酒店服務(wù)員辭職報告集錦(15篇)
- 西游記讀后感(匯編15篇)
- 春節(jié)小學作文集錦15篇
- 全球視角看珠寶產(chǎn)業(yè)
- 漢字的古詩4句
- 光伏租賃合同(2篇)
- 樓面傾斜處理方案
- 新SAT閱讀電子講義
- 《基業(yè)長青》讀書心得總結(jié)
- 團體建筑施工人員意外傷害保險條款(2012版)
- 合規(guī)性評價報告(2022年)
- 大連市小升初手冊
- 《自然辯證法》課后習題答案自然辯證法課后題答案
- 燃氣工程監(jiān)理實施細則(通用版)
- E車E拍行車記錄儀說明書 - 圖文-
- 人才梯隊-繼任計劃-建設(shè)方案(珍貴)
- 《健身氣功》(選修)教學大綱
- 王家?guī)r隧道工程地質(zhì)勘察報告(總結(jié))
評論
0/150
提交評論