2024年Java認(rèn)證筆試歷年真題薈萃含答案_第1頁
2024年Java認(rèn)證筆試歷年真題薈萃含答案_第2頁
2024年Java認(rèn)證筆試歷年真題薈萃含答案_第3頁
2024年Java認(rèn)證筆試歷年真題薈萃含答案_第4頁
2024年Java認(rèn)證筆試歷年真題薈萃含答案_第5頁
已閱讀5頁,還剩16頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

2024年Java認(rèn)證筆試歷年真題薈萃含答案(圖片大小可自由調(diào)整)第1卷一.參考題庫(共30題)1.11.?double?input?=?314159.26;? 12.?NumberFormat?nf=?NumberFormat.getInstance(Locale.ITALIAN);? 13.?String?b;? 14.?//insert?code?here? Which?code,?inserted?at?line?14,?sets?the?value?of?b?to?3?14.159,26?()?A、?b?=?nf.parse(?input);B、?b?=?nf.format(?input);C、?b?=?nf.equals(?input);D、?b?=?nf.parseObject(?input);2. And?MainClass?exists?in?the?/apps/com/company/application?directory.?Assume?the?CLASSPATH?environment?variable?is?set?to?"."?(current?directory).Which?two?java?commands?entered?at?the?command?line?will?run?MainClass?()A、java?MainClass?if?run?from?the?/apps?directoryB、java?pany.application.MainClass?if?run?from?the?/apps?directoryC、java?-classpath?/apps?pany.application.MainClass?if?run?from?any?directoryD、java-classpath?.?MainClass?if?run?from?the?/apps/com/company/application?directoryE、java?-classpath?/apps/com/company/application:.?MainClass?if?run?from?the?/apps?directoryF、java?pany.application.MainClass?if?run?from?the?/apps/com/company/application?directory3.Given?an?HttpServlet?Request?request?and?Http?Servlet?Response?response,?which?sets?a?cookie?“username”?with?the?value?“joe”?in?a?servlet.?()A、?request.add?Cookie?(“username”.?“joe”)B、?request.set?Cookie?(“username,?“joe”)C、?response.add?Cookie?(username”,?“joe”))D、?request.add?Header?(new?Cookie?(“username”,?“joe”))E、?request.add?Cookie?(new?Cookie?(“username”,?“joe”))F、?response.add?Cookie?(new?Cookie?(“username”,?“joe”))G、?response.add?Header?(new?Cookie?(“username”,?“joe”))4.有關(guān)new關(guān)鍵字的描述正確的是哪項(xiàng)?()?????A、創(chuàng)建對象實(shí)例的時(shí)候可以不使用new關(guān)鍵字B、new所創(chuàng)建的對象不占用內(nèi)存空間C、new會調(diào)用類的構(gòu)造器來創(chuàng)建對象D、new所創(chuàng)建的對象一定存在引用變量5.現(xiàn)有:? class??Test4??{? public?static?void?main?(String??[]??args)??{??? boolean?X=true;?? boolean?y=false;??? short?Z=42;??? if((z++==42)??&&??(y=true))z++;??? if((x=false)??||????(++z==45))??z++;??? System.?out.println(¨z=”+z);??? ?}??? }? 結(jié)果為:()?A、??Z=42B、??z=44C、??Z=?45D、??z=?466.1.?class?Calc?{? 2.?public?static?void?main(String?[]?args)?{? 3.?try?{? 4.?int?x?=?Integer.parseInt("42a");? 5.?//insert?code?here? 6.?System.out.print("oops?");? 7.?}? 8.?}? 9.?}? 下面哪兩行分別插入到第五行,會導(dǎo)致輸出“oops”?()A、}?catch?(ClassCastException?c)?{B、}?catch?(IllegalStateException?c)?{C、}?catch?(NumberFormatException?n)?{D、}?catch?(IllegalArgumentException?e)?{7. For?a?given?product?instance,?which?three?jsp:setProperty?attributes?must?be?used?to?initialized?its?properties?form?the?HTML?form??()A、?idB、?nameC、?typeD、?paramE、?propertyF、?reqParamG、?attribute8.public?void?test(int?x)?{? int?odd?=?x%2;? if?(odd)?{? ?System.out.println(“odd);? }?else?{? System.out.println(“even”);? }? }? Which?statement?is?true?()?A、Compilation?fails.B、?“odd”?will?always?be?output.C、?“even”?will?always?be?output.D、?“odd”?will?be?output?for?odd?values?of?x,?and?“even”?for?even?values.E、?“even”?will?be?output?for?add?values?of?x,?and?“odd”?for?even?values.9.java接口的方法修飾符可以為()。(忽略內(nèi)部接口)A、privateB、protectedC、finalD、abstract10.現(xiàn)有? import?java.io.PrintWriter;????? class??DoFormat{? public??static?void?main?(String??[]??args)??{????? int?x=42;? int?y=12345;???? float?Z-7?;? System.out.format("一%4d-",??X); System.?out.format("-%4d-",??y);???? System.?out.format("-%4.ld-",z);????? }????? }????? 結(jié)果為:()?????A、編譯失敗B、??-42-??-1234-?-7.0-C、?-?42-?-1234-?-7.0-D、?-?42-?-12345-?-7.0-E、運(yùn)行時(shí)異常被拋出11.public?class?Test?{? public?static?void?main(String?[]?args)?{? boolean?assert?=?true;? if(assert)?{? System.out.println(”assert?is?true”);? }? }? } Given:? javac?-source?1.3?Test.java? What?is?the?result?()?A、?Compilation?fails.B、?Compilation?succeeds?with?errors.C、?Compilation?succeeds?with?warnings.D、?Compilation?succeeds?without?warnings?or?errors.12.You?are?developing?several?tag?libraries?that?will?be?sold?for?development?of?third-party?web?applications.You?are?about?to?publish?the?first?three?libraries?as?JAR?files:?container-tags.jar,advanced-html-form-tags.jar,?and?basic-html-form-tags.jar. Which?two?techniques?are?appropriate?for?packaging?the?TLD?files?forthese?tag?libraries?()A、The?TLD?must?be?located?within?the?WEB-INF?directory?of?the?JAR?file.B、The?TLD?must?be?located?within?the?META-INF?directory?of?the?JAR?file.C、The?TLD?must?be?located?within?the?META-INF/tld/?directory?of?the?JAR?file.D、The?TLD?must?be?located?within?a?subdirectory?of?WEB-INF?directory?of?the?JAR?file.E、The?TLD?must?be?located?within?a?subdirectory?of?META-INF?directory?of?the?JAR?file.13.AnInterface?is?an?interface.?? AnAdapter0?is?a?non-abstract,?non-final?class?with?a?zero?argument?constructor.?? AnAdapter1?is?a?non-abstract,?non-final?class?without?a?zero?argument?constructor,?but?with?a?constructor?that?takes?one?int?argument.??? Which?two?construct?an?anonymous?inner?class?()???A、AnAdapter1?aa=new?AnAdapter1(){}B、AnAdapter0?aa=new?AnAdapter0(){}C、AnAdapter0?aa=new?AnAdapter0(5){}D、AnAdapter1?aa=new?AnAdapter1(5){}E、AnInterface?a1=new?AnInterface(5){}14.現(xiàn)有:?? class?Thread2?implements?Runnable?{?? void?run()?{?? System.out.print("go?");?? }?? public?static?void?main(String?[]?args)?{?? Thread2?t2?=?new?Thread2();?? Thread?t?=?new?Thread(t2);?? t.start();?? }?? }?? 結(jié)果為:()A、?goB、?編譯失敗C、?代碼運(yùn)行,無輸出結(jié)果D、?運(yùn)行時(shí)異常被拋出15.You?have?created?a?servlet?that?generates?weather?maps.?The?data?for?these?maps?is?calculated?by?aremote?host.?The?IP?address?of?this?host?is?usually?stable,?but?occasionally?does?have?to?change?as?thecorporate?network?grows?and?changes.?This?IP?address?used?to?be?hard?coded,?but?after?the?fifth?change?tothe?IP?address?in?two?years,?you?have?decided?that?this?value?should?be?declared?in?the?deploymentdescriptor?so?you?do?NOT?have?the?recompile?the?web?application?every?time?the?IP?address?changes. Which?deployment?descriptor?snippet?accomplishes?this?goal?()A、B、C、D、16.子類可以繼承父類的除私有成員以外的其它所有成員。17.A?JSP?page?needs?to?set?the?property?of?a?given?JavaBean?to?a?value?that?is?calculated?with?the?JSP?page. Which?three?jsp:setProperty?attributes?must?be?used?to?perform?this?initialization?()A、IdB、ValC、NameD、ParamE、ValueF、Property18.11.classSnoochy{ 12.Boochybooch; 13.publicSnoochy(){booch=newBoochy(this);} 14.} 15. 16.classBoochy{ 17.Snoochysnooch; 18.publicBoochy(Snoochys){snooch=s;} 19.} Andthestatements: 21.publicstaticvoidmain(String[]args){ 22.Snoochysnoog=newSnoochy(); 23.snoog=null; 24.//morecodehere 25.} Whichstatementistrueabouttheobjectsreferencedbysnoog,snooch,andboochimmediatelyafterline23executes?()A、Noneoftheseobjectsareeligibleforgarbagecollection.B、Onlytheobjectreferencedbyboochiseligibleforgarbagecollection.C、Onlytheobjectreferencedbysnoogiseligibleforgarbagecollection.D、Onlytheobjectreferencedbysnoochiseligibleforgarbagecollection.E、Theobjectsreferencedbysnoochandboochareeligibleforgarbagecollection.19.Which?four?statments?are?true?() A、Raccoon?is-a?Mammal.B、Raccoon?has-a?Mammal.C、BabyRaccoon?is-a?Mammal.D、BabyRaccoon?is-a?Raccoon.E、BabyRaccoon?has-a?Mammal.F、BabyRaccoon?is-a?BabyRaccoon.20.將一個(gè)正整數(shù)分解質(zhì)因數(shù)。例如:輸入90,打印出90=2*3*3*5。 程序分析:對n進(jìn)行分解質(zhì)因數(shù),應(yīng)先找到一個(gè)最小的質(zhì)數(shù)k,然后按下述步驟完成:???? (1)如果這個(gè)質(zhì)數(shù)恰等于n,則說明分解質(zhì)因數(shù)的過程已經(jīng)結(jié)束,打印出即可。???? (2)如果n??k,但n能被k整除,則應(yīng)打印出k的值,并用n除以k的商,作為新的正整數(shù)你n,重復(fù)執(zhí)行第一步。???? (3)如果n不能被k整除,則用k+1作為k的值,重復(fù)執(zhí)行第一步。21.選出不正確的敘述()。A、死鎖是指因相互競爭資源使得系統(tǒng)中有多個(gè)阻塞進(jìn)程的情況B、若系統(tǒng)中并發(fā)運(yùn)行的進(jìn)程和資源之間滿足互斥條件、占有且申請、不可搶占和環(huán)路條件,則可判定系統(tǒng)中發(fā)生了死鎖C、在對付死鎖的策略中,解除死鎖通常都是和檢測死鎖配套使用D、產(chǎn)生死鎖的原因可歸結(jié)為競爭資源和進(jìn)程推進(jìn)順序不當(dāng)E、在死鎖的解決方法中,由于避免死鎖采用靜態(tài)分配資源策略,所以對資源的利用率不高22.11.publicstaticvoidmain(String[]args){ 12.Objectobj=newint[]{1,2,3}; 13.int[]someArray=(int[])obj; 14.for(inti:someArray)System.out.print(i+"") 15.} Whatistheresult?()A、123B、Compilationfailsbecauseofanerrorinline12.C、Compilationfailsbecauseofanerrorinline13.D、Compilationfailsbecauseofanerrorinline14.E、AClassCastExceptionisthrownatruntime.23.設(shè)有方法: 則b可以為()A、nullB、b的類型為AC、b的類型為A的子類D、b的類型為A的父類24.以下涉及到內(nèi)存管理的代碼段中,有錯(cuò)誤的是:()。 A、AB、BC、CD、D25.A?developer?wants?a?web?application?to?be?notified?when?the?application?is?about?to?be?shut?down. Whichtwo?actions?are?necessary?to?accomplish?this?goal?()A、Include?a?listener?directive?in?a?JSP?pageB、configure?a?listener?in?the?TLD?file?using?the??elementC、Include?a??element?in?the?web?application?deployment?descriptorD、configure?a?listener?in?the?application?deployment?descriptor,?using?the??elementE、Include?a?class?implementing?ServletContextListener?as?part?of?the?web?application?deploymen26.運(yùn)行時(shí),數(shù)組以哪種方式存在?()??A、對象?B、基本類型變量?C、引用類型變量?D、視具體情況而定27.以下哪個(gè)不是Collection的子接口()A、?ListB、?SetC、?MapD、?SortedSet28.線程安全的map在JDK1.5及其更高版本環(huán)境有哪幾種方法可以實(shí)現(xiàn)()。A、Map?map?=?new?HashMap()B、Map?map?=?new?TreeMap()C、Map?map?=?new?ConcurrentHashMap()D、Map?map?=?Collections.synchronizedMap(new?HashMap())29.interface?Altitude?{? //insert?code?here?? }?? 和4個(gè)聲明:?? int?HIGH?=?7;? public?int?HIGH?=?7;??? abstract?int?HIGH?=?7;?? interface?int?HIGH?=?7;? 分別插入到第2行,有多少行可以編譯?()??A、?0B、?1C、?2D、?3E、?430.A?developer?is?designing?the?presentation?tier?for?a?web?application?that?relies?on?a?complex?session?bean.The?session?bean?is?still?being?developed?and?the?APIs?for?it?are?NOT?finalized.?Any?changes?to?the?sessionbean?API?directly?impacts?the?development?of?the?presentation?tier.? Which?design?pattern?provides?a?meansto?manage?the?uncertainty?in?the?API?()A、View?HelperB、Front?ControllerC、Composite?ViewD、Intercepting?FilterE、Business?Delegate第1卷參考答案一.參考題庫1.參考答案:B2.參考答案:B,C3.參考答案:F4.參考答案:C5.參考答案:D6.參考答案:C,D7.參考答案:A,D,G8.參考答案:A9.參考答案:D10.參考答案:E11.參考答案:C12.參考答案:B,E13.參考答案:B,D14.參考答案:B15.參考答案:D16.參考答案:正確17.參考答案:C,E,F18.參考答案:E19.參考答案:A,B,C,F20.參考答案:21.參考答案:A,B22.參考答案:A23.參考答案:A,B,C24.參考答案:A,B,D25.參考答案:D,E26.參考答案:A27.參考答案:C28.參考答案:C,D29.參考答案:C30.參考答案:E第2卷一.參考題庫(共30題)1.如何引用包中的某個(gè)類?如何引用整個(gè)包?如果編寫JavaApplet程序時(shí)想把整個(gè)java.a(chǎn)pplet包都加載,則應(yīng)該怎么做?2.javax.swing.Timer將按一定頻率產(chǎn)生什么事件()A、ActionEventB、TimerEventC、ItemEventD、InputEvent3.Click?the?’Select?and?Place’?button. Place?the?events?in?the?order?they?occur. 4.Which?is?a?benefit?of?precompiling?a?JSP?page?()A、It?avoids?initialization?on?the?first?request.B、It?provides?the?ability?to?debug?runtime?errors?in?the?application.C、It?provides?better?performance?on?the?first?request?for?the?JSP?page.D、It?avoids?execution?of?the?_jspService?method?on?the?first?request.5.For?which?three?events?can?web?application?event?listeners?be?registered?()A、When?a?session?is?createdB、After?a?servlet?is?destroyedC、When?a?session?has?timed?outD、When?a?cookie?has?been?createdE、When?a?servlet?has?forwarded?a?requestF、When?a?session?attribute?value?is?changed6.現(xiàn)有:D?? -?f?是一個(gè)對?java.io.File?實(shí)例的合法引用?? -?fw?是一個(gè)對?java.io.FileWriter?實(shí)例的合法引用?? -?bw?是一個(gè)對?java.io.BufferedWriter?實(shí)例的合法引用?? 以下哪一項(xiàng)無效?()??A、?PrintWriter?prtWtr?=?new?PrintWriter(f);B、?PrintWriter?prtWtr?=?new?PrintWriter(fw);C、?PrintWriter?prtWtr?=?new?PrintWriter(bw);D、?BufferWriter?bufWtr?=?new?BufferedWriter(f);E、?BufferWriter?bufWtr?=?new?BufferedWriter(fw);F、?BufferWriter?bufWtr?=?new?BufferedWriter(bw);7.實(shí)例方法是根據(jù)引用變量的聲明類型進(jìn)行訪問的8.A?developer?for?the?C?web?site?has?been?told?that?users?may?turn?off?cookie?support?in?their?browsers.?What?must?the?developer?do?to?ensure?that?these?customers?can?still?use?the?web?application?()??A、?The?developer?must?ensure?that?every?URL?is?properly?encoded?using?the?appropriate?URL?rewriting?APIsB、?The?developer?must?provide?an?alternate?mechanism?for?managing?sessions?and?abandon?theHttpSession?mechanism?entirelyC、?The?developer?can?ignore?this?issue.?Web?containers?are?required?to?support?automatic?URL?rewriting?when?cookies?are?not?supportedD、?The?developer?must?ass?the?string??id=?to?the?end?of?every?URL?to?ensure?that?the?conversion?with?the?browser?can?continue.9.You?are?writing?a?JSP?that?includes?scriptlet?code?to?declare?a?List?variable?and?initializes?that?variable?to?anArrayList?object. Which?two?JSP?code?snippets?can?you?use?to?import?these?list?types?()A、B、C、D、E、F、10.拍七游戲打印出"拍七"游戲規(guī)則:大家依次從1開始順序數(shù)數(shù),數(shù)到含有7或7的倍數(shù)的要拍手或其它規(guī)定的方式表示越過(比如:7,14,17等都不能數(shù)出),下一人繼續(xù)數(shù)下面的數(shù)字。違反規(guī)則者受罰。11.HTTP中的POST和GET在下列哪些方面有區(qū)別()。A、數(shù)據(jù)位置B、明文密文C、數(shù)據(jù)安全D、長度限度E、應(yīng)用場景12.求四位的水仙花數(shù)。即滿足這樣條樣的四位數(shù):各位數(shù)字的4次方和等于該數(shù)自身。13.窗口監(jiān)聽器有哪些特點(diǎn)?()A、可以繼承窗口適配器(WindowAdapter)類,并覆寫其中需要用到的函數(shù)B、窗口監(jiān)聽器所實(shí)現(xiàn)的接口是WindowListener,它有多?個(gè)函數(shù)C、窗口監(jiān)聽器可以只實(shí)現(xiàn)WindowListener接口中的一兩個(gè)函數(shù)D、響應(yīng)窗口打開,關(guān)閉,最小化成圖標(biāo),由圖標(biāo)還原,激活,無效,最大化,還原,獲取焦點(diǎn),失去作業(yè)點(diǎn)等事件E、僅在Windows操作系統(tǒng)下有效14.下面哪個(gè)類不能直接讀取磁盤文件()A、FileReaderB、RandomAccessFileC、FilterReaderD、FileInputStream15.1.?int?I=1,?j=0? 2.??? 3.?switch(i)??{? 4.?case?2:? 5.?j+=6;? 6.??? 7.?case?4:? 8.?j+=1;? 9.??? 10.?default:? 11.?j?+=2;? 12.??? 13.?case?0:? 14.?j?+=4;? 15.?}? 16.????? What?is?the?value?of?j?at?line?16?()A、?0B、?1C、?2D、?4E、?616.Which?four?are?true?()A、?Has-a?relationships?should?never?be?encapsulated.B、?Has-a?relationships?should?be?implemented?using?inheritance.C、?Has-a?relationships?can?be?implemented?using?instance?variables.D、?Is-a?relationships?can?be?implemented?using?the?extends?keyword.E、?Is-a?relationships?can?be?implemented?using?the?implements?keyword.F、?An?array?or?a?collection?can?be?used?to?implement?a?one-to-many?has-a?relationship.G、?The?relationship?between?Movie?and?Actress?is?an?example?of?an?is-a?relationship.17.內(nèi)存垃圾回收將刪除無法訪問的對象18.What?is?the?result?() A、Compilation?fails.B、Cannot?add?ToppingsC、The?code?runs?with?no?output.D、A?NullPointerException?is?thrown?in?Line?14.19.What?will?be?written?to?the?standard?output?when?the?following?program?is?run?()?? public?class?Q8499?{?? public?static?void?main(String?args[])?{? double?d?=?-2.9;?? int?i?=?(int)?d;? i?*=?(int)?Math.ceil(d);? i?*=?(int)?Math.abs(d);?? System.out.println(i);? ?}? ?}A、12B、18C、8D、9E、2720.為將數(shù)組myArray的長度由6改為10,現(xiàn)采取以下編碼:? int[]?myArray?=?new?int[6];? myArray?=?new?int[10];?? 代碼執(zhí)行后,以下敘述哪項(xiàng)是正確的?()?A、?數(shù)組myArray的長度已由6改為10,其中前6個(gè)元素的值不變,后四個(gè)元素的值為空。B、?數(shù)組myArray的長度已由6改為10,其中前6個(gè)元素的值不變,后四個(gè)元素需再經(jīng)過初始化后才能使用。C、?數(shù)組myArray的長度已由6改為10,原來6個(gè)元素的值全部丟失。D、?數(shù)組myArray的長度沒有變化。21.public?class?Threads2?implements?Runnable?{? public?void?nun()?{? System.out.println(”run.”);? throw?new?RuntimeException(”Problem”);? }? public?static?void?main(String[]?args)?{? Thread?t?=?new?Thread(new?Threads2());? t.start();? System.out.println(”End?of?method.”);? }? }? Which?two?can?be?results?()A、?java.lang.RuntimeException:?ProblemB、?run.

java.lang.RuntimeException:?ProblemC、?End?of?method.

java.lang.RuntimeException:?ProblemD、?End?of?method.?

run.

java.lang.RuntimeException:?ProblemE、?run.

java.lang.RuntimeException:?Problem?

End?of?method.22.java中,用()關(guān)鍵字定義常量。A、finalB、#defineC、floatD、const23.A?C?developer?is?designing?the?presentation?tier?for?a?web?application?that?relies?on?a?complex?session?bean.?The?session?bean?is?still?being?developed?and?the?APIs?for?are?NOT?finalized.?Any?changes?to?the?session?bean?API?directly?impacts?the?development?of?the?presentation?tier.? Which?design?pattern?provides?a?means?to?manage?the?uncertainty?in?the?API?()A、?View?HelperB、?Front?ControllerC、?Composite?ViewD、?Intercepti

溫馨提示

  • 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)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論