Java認證筆試(2018-2023年)真題摘選含答案_第1頁
Java認證筆試(2018-2023年)真題摘選含答案_第2頁
Java認證筆試(2018-2023年)真題摘選含答案_第3頁
Java認證筆試(2018-2023年)真題摘選含答案_第4頁
Java認證筆試(2018-2023年)真題摘選含答案_第5頁
已閱讀5頁,還剩42頁未讀, 繼續(xù)免費閱讀

下載本文檔

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

文檔簡介

長風破浪會有時,直掛云帆濟滄海。Java認證筆試(2018-2023年)真題摘選含答案(圖片大小可自由調(diào)整)卷I一.參考題庫(共30題)1.C++中構(gòu)造函數(shù)和析構(gòu)函數(shù)可以拋出異常嗎()。A、都不行B、都可以C、只有構(gòu)造函數(shù)可以D、只有析構(gòu)函數(shù)可以2.如何引用包中的某個類?如何引用整個包?如果編寫JavaApplet程序時想把整個java.a(chǎn)pplet包都加載,則應(yīng)該怎么做?3.編寫一個程序,能將一個Java源程序中的空行及注釋去掉。4.What?is?the?numerical?range?of?a?char?()??A、?0?.?.?.?32767B、?0?.?.?.?65535C、?–256?.?.?.?255D、?–32768?.?.?.?32767E、?Range?is?platform?dependent.5.在linux系統(tǒng)中,有一個文件夾里面有若干文件,通常用哪個命令可以獲取這個文件夾的大?。ǎ?。A、ls?–hB、du?–shC、df?–D、fdish?-h6.建立一個銀行賬戶類,要求能夠存放用戶的賬號、姓名、密碼和賬戶余額等個人信息,并包含存款、取款、查詢余額和修改賬戶密碼等操作,并用此類創(chuàng)建對象,對象的賬號為100,姓名為Tom,密碼為11111,賬戶余額為10000。7. Which?two?are?true()A、?Line?13?is?not?valid?for?a?servlet?declarationB、?Line?14?is?not?valid?for?a?servlet?declarationC、?One?instance?of?the?servlet?will?be?loaded?at?startupD、?Ten?instance?of?the?servlet?will?be?loaded?at?start?upE、?the?servlet?will?be?referenced?by?the?name?catalog?in?mappings8.下面的代碼讀取并打印文本文件,請修改正確。 9.以下關(guān)于中斷控制語句的描述,錯誤的是()A、?return用于退出整個子程序B、?continue停止繼續(xù)執(zhí)行下面的語句,直接跳回循環(huán)起始位置C、?break用于強行退出循環(huán),不執(zhí)行循環(huán)中剩余的語句D、?break語句用于中斷當前的程序塊,如for循環(huán)塊,if結(jié)構(gòu)塊等的執(zhí)行E、?在一個函數(shù)中,不管有沒有返回值,都需要return語句來推出函數(shù)10.class?Guy?{?String?greet()?{?return?"hi?";?}?}? class?Cowboy?extends?Guy?{?String?greet()?{?return?"howdy?";?}?}? class?Wrangler?extends?Cowboy?{?String?greet()?{?return?"ouch!?";?}?}? class?Greetings2?{? public?static?void?main(String?[]?args)?{? Guy?g?=?new?Wrangler();? Guy?g2?=?new?Cowboy();? Wrangler?w2?=?new?Wrangler();? System.out.print(g.greet()+g2.greet()+w2.greet());? }? }? 結(jié)果是什么?()?A、hi?hi?ouch!B、hi?howdy?ouch!C、ouch!?howdy?ouch!D、編譯失敗11.簡述Java的事件處理機制。12.下列有關(guān)Swing的敘述,哪項錯誤()?????A、Swing是Java基礎(chǔ)類(JFC)的組成部分B、Swing是可用來構(gòu)建GUI的程序包C、Swing是AWT圖形T具包的替代技術(shù)D、Java基礎(chǔ)類(JFC)是Swing的組成部分13.有工人,農(nóng)民,教師,科學家,服務(wù)生,其中,工人,農(nóng)民,服務(wù)生只有基本工資.教師除基本工資外,還有課酬(元/天),科學家除基本工資外,還有年終獎,請你寫出相關(guān)類,將各種類型的員工的全年工資打印出來14.Which&ensp;can&ensp;be&ensp;used&ensp;to&ensp;encode&ensp;charS&ensp;for&ensp;output?()A、?Java.io.OutputStream.B、?Java.io.OutputStreamWriter.C、?Java.io.EncodeOutputStream.D、?Java.io.EncodeWriter.E、?Java.io.BufferedOutputStream.15.下面哪種布局方式只影響控件的高度,而不影響寬度()A、BorderLayout的WEST和EASTB、BorderLayout的NORTH和SOUTHC、GridLayoutD、FlowLayout16.以下異常中,不屬于Runtimeexception的是()??????A、NullPointerExeption,使用未初始化的引用變量B、IndexOutofBondsException,數(shù)組下標越界異常C、IllegalAccessException,沒有足夠的權(quán)限訪問其他類的成員D、ArithmeticException,算術(shù)異常17.public?class?SomeException?{? }?Class?a:? public?class?a?{? public?void?doSomething()?{?}? }?Class?b:? public?class?b?extends?a?{? public?void?doSomething()?throws?SomeException?{?}? }? Which?is?true?about?the?two?classes?()?A、?Compilation?of?both?classes?will?fail.B、?Compilation?of?both?classes?will?succeed.C、?Compilation?of?class?a?will?fail.?Compilation?of?class?b?will?succeed.D、?Compilation?of?class?a?will?fail.?Compilation?of?class?a?will?succeed.18.1.?class?A?{? 3.?public?String?to?String()?{? 4.?return?“4”;? 5.?}? 6.?}? 7.?class?B?extends?A?{? 8.?public?String?toString()?{ 9.?return?super.toString()?+?“3”;? 10.?}? 11.?}? 12.?public?class?Test?{? 13.?public?static?void?main?(String[]?args)?{? 14.?System.out.printIn(new?B()); 15.?}? 16.?}?? What?is?the?result()??? A、?Compilation?succeeds?and?4?is?printed.B、?Compilation?……………?is?printed.C、?An?error?on?line?9?cause?compilation?to?fail.D、?An?error?on?line?14?cause?compilation?to?fail.E、?Compilation?succeeds?but?an?exception?is?thrown?at?line?9.19.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、?620.猴子摘桃問題猴子第1天摘下若干桃子,當即吃掉一半,又多吃一個,第二天將剩余的部分吃掉一半還多一個;以此類推,到第10天只剩余1個。問第1天共摘了多少桃子21.如何調(diào)用java小程序()A、雙擊小程序文件即可執(zhí)行B、在命令方式下鍵入java命令來調(diào)用C、在JBuilder中鍵入java命令來調(diào)用D、打開HTML文件即可調(diào)用,或者利用appletviewer命令調(diào)用22.編寫Applet程序,用paint()方法顯示一行字符串,Applet包含兩個按鈕“放大”和“縮小”,當用戶單擊“放大”時顯示的字符串字體放大一號,單擊“縮小”時顯示的字符串字體縮小一號。23.以下關(guān)于框架和其他窗口之間的關(guān)系中,錯誤的是()??A、?對話框必須依附于某個框架B、?當框架最小化時,所有依附于它的窗口也會最小化C、?框架是一個程序的主窗口,每個具有圖形界面的程序都至少要有一個框架D、?內(nèi)部框架也是頂級容器組件24.Which?three?methods,?inserted?individually?at?line?14,?will?correctly?complete?class?Two?() A、int?foo(){/*?more?code?here?*/}B、void?foo(){/*?more?code?here?*/}C、public?void?foo(){/*?more?code?here?*/}D、private?void?foo(){/*?more?code?here?*/}E、protected?void?foo(){/*?more?code?here?*/}25.Which?three?occur?during?JSP?page?translation?()A、?The?jspInit?method?is?called.B、?The?JSP?page?implementation?class?is?created.C、?The?JSP?page?implementation?class?is?compiled.D、?The?JSP?page?is?validated?for?syntatic?correctness.E、?The?associated?tag?files?are?validated?for?syntatic?correctness.26.求三位數(shù)中,個位數(shù)字與十位數(shù)字之和除以10所得的余數(shù)是百位數(shù)字,且百位數(shù)字是偶數(shù)的數(shù)的個數(shù)。27.int?i?=?0,?j?=?5;? tp;?? for?(;;)?{? i++;? for(;;)?{? if?(i>?--j)?{? break?tp;? break?tp;? }? }? System.out.println(“i=”?+i?“,j?=”+j); } What?is?the?result?()??A、?i?=?1,?j?=?0B、?i?=?1,?j?=?4C、?i?=?3,?j?=?4D、?i?=?3,?j?=?0E、?Compilation?fails.28.在x86系統(tǒng)下,sizeof如下結(jié)構(gòu)體的值是多少()。 A、20B、22C、24D、2629.程序員已經(jīng)創(chuàng)建了一個類,該類的實例可以用做Hashtable?的鍵(key)。哪兩項是對的?()????A、該類有一個返回類型為?int?的?equals?方法。B、該類有一個返回類型為?boolean?的?equals?方法。C、該類有一個接收一個參數(shù)的?equals?方法。D、該類有一個接收兩個參數(shù)的?equals?方法。30.用于生成Java文檔的JDK工具是?()?A、javacB、jdbC、javadocD、junit卷I參考答案一.參考題庫1.參考答案:C2.參考答案: 為了能使用Java中已提供的類,我們需要用import語句來引入所需要的類。import語句的格式為: I.mportpackage1[.package2…].(classname *); 其中package1[.package2…]表明包的層次,與package語句相同,它對應(yīng)于文件目錄,classname則指明所要引入的類,如果要從一個包中引入多個類,則可以用星號(*)來代替。例如: I.mportjava.awt.*; I.mportjava.util.Date; 如果編寫JavaApplet程序時想把整個java.applet包都加載,可以使用: I.mportjava.applet.*;3.參考答案: 4.參考答案:B5.參考答案:B6.參考答案:7.參考答案:C,E8.參考答案: 9.參考答案:D,E10.參考答案:C11.參考答案: 在Java中通過實現(xiàn)事件監(jiān)聽器(Eventistener)來實現(xiàn)對事件的處理。事件監(jiān)聽器是一些事件的接口,這些接口是java.awt.AWTEventListener的子類。接口中含有相關(guān)的方法,每個方法中可以編程來處理相關(guān)的事件。 每個界面對象在需要處理某種事件時,先進行事件的注冊。注冊的過程就是將界面對象與事件監(jiān)聽器聯(lián)系在一起的過程。12.參考答案:D13.參考答案:14.參考答案:B15.參考答案:A16.參考答案:C17.參考答案:D18.參考答案:B19.參考答案:A,E20.參考答案:21.參考答案:D22.參考答案: 23.參考答案:D24.參考答案:B,C,E25.參考答案:B,C,D26.參考答案:27.參考答案:B,D28.參考答案:C29.參考答案:B,C30.參考答案:C卷II一.參考題庫(共30題)1.java?Thread中,run方法和start方法的區(qū)別,下面說法錯誤的是()。 A、AB、BC、CD、D2.已知: 那么結(jié)果為?()A、AmB、BmC、BmAm??D、編譯錯誤3.Given?classes?defined?in?two?different?files:? 1.?package?util;? 2.?public?class?BitUtils?{? 3.?private?static?void?process(byte[]?b)?{?}? 4.?}? 1.?package?app;? 2.?public?class?SomeApp?{? 3.?public?static?void?main(String[]?args)?{? 4.?byte[]?bytes?=?new?byte[256];? 5.?//?insert?code?here? 6.?}? 7.?}? What?is?required?at?line?5?in?class?SomeApp?to?use?the?process?method?of?BitUtils?()?A、?process(bytes);B、?BitUcess(bytes);C、?app.BitUcess(bytes);D、?util.BitUcess(bytes);E、?import?util.BitUtils.?*;?process(bytes);F、?SomeApp?cannot?use?the?process?method?in?BitUtils.4.下列有關(guān)多態(tài)的敘述正確的是哪項()?????A、父類的引用指向子類的實例是一種多態(tài)B、子類的引用指向子類的實例是一種多態(tài)C、接口的引用指向?qū)崿F(xiàn)該接口類的實例是一種多態(tài)D、抽象類的引用指向抽象類的實例是一種多態(tài)5.面板缺省搭配是什么布局管理器?()?A、邊界布局管理器B、盒式布局管理器C、表格型布局管理器D、流式布局管理器6.現(xiàn)有:? class?HorseRadish??{????? //insert?code?here? protected?HorseRadish?(int?x)????{????? System.out.println?("bok?choy");????? }????? }? class?Wasabi?extends?HorseRadish??{? public?static?void?main?(String??[]??args){??? Wasabi?w-?new?Wasabi();???? }???? }? 分別插入到第2行,哪兩項允許代碼編譯并產(chǎn)生”bok?choy”輸出結(jié)果()A、?protected?HorseRadish()??{this?(42);}B、??protected?HorseRadish()??{}C、??//just?a?commentD、??protected??HorseRadish()??{??new?HorseRadish?(42);}7.編寫一個Java程序在屏幕上輸出“你好!”。8.class?Car?implements?Serializable?{?}?? class?Ford?extends?Car?{?}?? 如果試圖序列化一個Ford實例,結(jié)果為()??A、編譯失敗B、一個對象被序列化C、兩個對象被序列化D、運行時異常被拋出9.以下關(guān)于應(yīng)用程序主類的描述,哪項錯誤?()??A、啟動java應(yīng)用程序的命令是javaB、應(yīng)用程序主類是應(yīng)用程序的入口點,也可稱之為應(yīng)用程序啟動類C、應(yīng)用程序主類中必須含有main方法,main方法的簽名是public?static?void?main(String[]?args){}D、只有應(yīng)用程序主類可以包含main方法,其它類不可以10.10.?class?Inner?{? 11.?private?int?x;? 12.?public?void?setX(?int?x)?{?this.x?=?x;?}? 13.?public?int?getX()?{?return?x;?}? 14.?}? 15.? 16.?class?Outer?{? 17.?private?Inner?y;? 18.?public?void?setY(?Inner?y)?{?this.y?=?y;?}? 19.?public?Inner?getY()?{?return?y;?}? 20.?}? 21.? 22.?public?class?Gamma?{? 23.?public?static?void?main(?String[]?args)?{ 24.?Outer?o?=?new?Outer(); 25.?Inner?i?=?new?Inner();? 26.int?n=10;? 27.?i.setX(n);? 28.?o.setY(i);? 29.?//?insert?code?here? 30.?System.out.println(?o.getY().getX());? 31.?}? 32.?}? Which?three?code?fragments,?added?individually?at?line?29,?produce?the?output?100?()A、?n?=?100;B、?i.setX(?100);C、?o.getY().setX(?100);D、?i?=?new?Inner();?i.setX(?100);E、?o.setY(?i);?i?=?new?Inner();?i.setX(?100);F、?i?=?new?Inner();?i.setX(?100);?o.setY(?i);11.public?class?test?(????? private?static?int?j?=?0;? private?static?boolean?methodB(int?k)?(? j?+=?k;? return?true;? )? public?static?void?methodA(int??i)(? boolean?b:???? b?=?i?<?10?|?methodB?(4);? b?=?i?<?10?||?methodB?(8);? )? public?static?void?main?(String?args[])(?? methodA?(0);? system.out.printIn(j);? )? )?? What?is?the?result?()??A、?The?program?prints?“0”B、?The?program?prints?“4”C、?The?program?prints?“8”D、?The?program?prints?“12”E、?The?code?does?not?complete.12.Which?statements?can?be?inserted?at?the?indicated?position?in?the?following?code?to?make?the?program?write?1?on?the?standard?output?when?run?()? public?class?Q4a39?{? int?a?=?1;?? int?b?=?1;?? int?c?=?1;?? class?Inner?{?? int?a?=?2;??int?get()?{?? int?c?=?3;?? //?insert?statement?here??return?c;? ?}?? }??Q4a39()?{?? Inner?i?=?new?Inner();?? System.out.println(i.get());??}?? public?static?void?main(String?args[])?{? ?new?Q4a39();? ?}?? }??A、c?=?b;B、c?=?this.a;C、c?=?this.b;D、c?=?Q4a39.this.a;E、c?=?c;13.Component類有何特殊之處?其中定義了哪些常用方法?14.為student類定義構(gòu)造方法初始化所有的域,增加一個方法publicStringtoString()把Sttldent類對象的所有域信息組合成一個字符串。編寫Application程序檢驗新增的功能。15.Which?two?prevent?a?servlet?from?handling?requests.?()A、?The?servlet’s?init?method?returns?a?non-zero?status.B、?The?servlet’s?init?method?throws?a?Servlet?ExceptionC、?The?servlet’s?init?method?sets?the?Servlet?Response’s?context?length?to?0D、?The?servlet’s?init?method?sets?the?Servlet?Response’s?content?type?to?null.E、?The?servlet’s?init?method?does?NOT?return?within?a?time?period?defined?by?the?servletcontainer.16.下面哪些說明是正確的()A、可以在類中定義類B、可以在類中定義方法C、可以在方法中定義類D、可以在方法中定義方法17.數(shù)組元素所占用的內(nèi)存位于()??A、數(shù)據(jù)區(qū)(Data)B、代碼區(qū)(Code)C、堆(Heap)D、堆棧(Stack)18.Which?thestatement?is?true?about?web?container?session?management()?A、?Access?to?session-scoped?attributes?is?guaranteed?to?be?thread-safe?by?the?web?container.B、?To?activate?URL?rewriting,?the?developer?must?use?the?HttpServletResponse.setURLRewriting?method.C、?If?the?web?application?uses?HTTPS,?then?the?web?container?may?use?the?data?on?the?HTTPS?request?stream?to?identify?the?client.D、?The?JSESSIONID?cookie?is?stored?permanently?on?the?client?so?that?a?user?may?return?to?the?web?application?and?the?web?container?will?rejoin?that?session.19.已知Sn=A1+A2+A3+...+An,其中,當n為奇數(shù)時An=n-1,當n為偶數(shù)時,An=n+1.例如:S6=0+3+2+5+4+7,求:S60=A1+A2+A3+...+A60.20.如何將一個類放到包里?()A、在類的源文件開始外寫上“package”關(guān)鍵字,后面跟包名;B、在類的源文件開始外寫上包名;C、在類的源文件開始外寫上包名,后面跟“package”?關(guān)鍵字;D、將包名作為源文件名;21.Which?is?thetruechoice?about?the?web?container?request?processing?model()?A、?The?init?method?on?a?filter?is?called?the?first?time?a?servlet?mapped?to?that?filter?is?invokedB、?A?filter?defined?for?a?servlet?must?always?forward?control?to?the?next?resource?in?the?filter?chain.C、?Filters?associated?with?a?named?servlet?are?applied?in?the?order?they?appear?in?the?web?application?deployment?descriptor?fileD、?If?the?init?method?on?a?filter?throws?an?UnavailableException,?then?the?container?will?make?no?further?attempt?to?execute?it22.兩個字符串連接程序23.Consider?the?following?code: Which?test?would?return?true()。 A、AB、BC、CD、DE、E24.public?class?test(? public?static?void?main(string[]args){? string?foo?=?args?[1];? string?foo?=?args?[2];? string?foo?=?args?[3];? }? )? And?command?line?invocation:?Java?Test?red?green?blue?? What?is?the?result?()??A、?Baz?has?the?value?of?“”B、?Baz?has?the?value?of?nullC、?Baz?has?the?value?of?“red”D、?Baz?has?the?value?of?“blue”E、?Bax?has?the?value?of?“green”F、?The?program?throws?an?exception.25.A?developer?is?designing?a?multi-tier?web?application?and?discovers?a?need?to?log?each?incoming?client?request.?Which?two?patterns,?taken?independently,?provide?a?solution?for?this?problem??()A、?Transfer?ObjectB、?Service?LocatorC、?Front?ControllerD、?Intercepting?FilterE、?Business?DelegateF、?Model-View-Controller26. The?attribute?“name”?has?a?value?of?“Foo,”?? What?is?the?result?if?this?tag?handler’s?tag?is?invoked?()A、?FooB、?doneC、?FoodoneD、?An?exception?is?thrown?at?runtime.E、?Compilation?fails?because?of?an?error?in?this?code.27.What?writes?the?text?“?”?to?the?end?of?the?file?“file.txt”?()A、?OutputStream?out=?new?FileOutputStream?(“file.txt”);??

Out.writeBytes?(“?/n”);B、?OutputStream?os=?new?FileOutputStream?(“file.txt”,?true);??

DataOutputStream?out?=?new?DataOutputStream(os);??out.writeBytes?(“?/n”);C、?OutputStream?os=?new?FileOutputStream?(“file.txt”);??

DataOutputStream?out?=?new?DataOutputStream(os);??out.writeBytes?(“?/n”);D、?OutputStream?os=?new?OutputStream?(“file.txt”,?true);?

?DataOutputStream?out?=?new?DataOutputStream(os);??out.writeBytes?(“?/n”);28.對于滿足SQL92標準的SQL語句:? select?foo,count(foo)from?pokes?where?foo>10group?by?foo?having?count?(*)>5?order?by?foo?? 其執(zhí)行順序應(yīng)該是()。A、FROM->WHERE->GROUP?BY->HAVING->SELECT->ORDER?BYB、FROM->GROUP?BY->WHERE->HAVING->SELECT->ORDER?BYC、FROM->WHERE->GROUP?BY->HAVING->ORDER?BY->SELECTD、FROM->WHERE->ORDER?BY->GROUP?BY->HAVING->SELECT29.Which?code?fragments?will?succeed?in?initializing?a?two-dimensional?array?named?tab?with?a?size?that?will?cause?the?expression?tab[3][2]?to?access?a?valid?element?()?? CODE?FRAGMENT?a:??int[

溫馨提示

  • 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. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論