




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
iiiitheprogrammerhasamechanismthatexplicityandimmediatelyfreesthememoryusedbyjavaobjects.thegarbagecollectionmechanismcanfreethememoryusedbyjavaobjectatexplectiontime.thegarbagecollectionsystemneverreclaimsmemoryfromobjectswhilearestillaccessibletorunninguserthreads.1。b、ejava的垃圾回收機(jī)制是通過一個(gè)后臺(tái)系統(tǒng)級(jí)線程對(duì)內(nèi)存分配情況進(jìn)行跟蹤實(shí)現(xiàn)的,對(duì)程序員來說是透明的,程序員沒有任何方式使無用內(nèi)存顯示的、立即的被釋放。而且它是在程序運(yùn)行期間發(fā)生的。答案b告訴我們程序員可以使一個(gè)本地變量失去任何意義,例如給本地變量賦值為null;答案e告訴我們在程序運(yùn)行期間不可能完全釋放內(nèi)存。givethefollowingmethod:publicvoidmethod(){stringa,b;a=newstring(helloworld);b=newstring(gameover);system.out.println(a+b+ok);a=null;a=b;system.out.println(a);}intheabsenceofcompileroptimization,whichistheearliestpointtheobject areferedisdefinitelyelibiletobegarbagecollection.a.beforeline3b.beforeline5beforeline6d.beforeline7beforeline92。d第6行將null賦值給a以后,a以前保存的引用所指向的內(nèi)存空間就失去了作用,它可能被釋放。所以對(duì)象a可能最早被垃圾回收是在第7行以前,故選擇d選項(xiàng)。intheclassjava.awt.awtevent,whichistheparentclassuponwhichjdkl.1awteventsarebasedthereisamethodcalledgetidwhichphraseaccuratelydescribesthereturnvalueofthismethod?hecaseofamouseclick,itisanindicationofthetextunderthemouseatthetimeoftheevent.ittellsthestateofcertainkeysonthekeybordatthetimeoftheevent.itisanindicationofthetimeatwhichtheeventoccurred.3。b請(qǐng)查閱java類庫。getid方法的返回值是eventtype。在認(rèn)證考試中,總會(huì)有類似的書本以外的知識(shí),這只能靠多實(shí)踐來增長知識(shí)了。whichstatementaboutlisteneristrue?mostcomponentallowmultiplelistenerstobeadded.ifmultiplelistenerbeaddtoasinglecomponent,theeventonlyaffectedoneponentdon?tallowmultiplelistenerstobeadd.thelistenermechanismallowsyoutocallanaddxxxxlistenermethodasmanytimesasisneeded,specifyingasmanydifferentlistenersasyourdesignrequire.4。a、d控件可以同時(shí)使用多個(gè)addxxxxlistener方法加入多個(gè)監(jiān)聽器。并且當(dāng)多個(gè)監(jiān)聽器加入到同一控件中時(shí),事件可以響應(yīng)多個(gè)監(jiān)聽器,響應(yīng)是沒有固定順序的。5.givethefollowingcode:publicclassexample{publicstaticvoidmain(stringargs口){intl=0;do{system.out.println(doingitforlis:+l);}while(--l0)system.out.println(finish);}}whichwellbeoutput:doingitforlis3doingitforlis1doingitforlis2doingitforlis0doingitforlis?c1finish5。d、f本題主要考察考生對(duì)流程控制的掌握情況。這是當(dāng)型循環(huán),條件為真執(zhí)行,條件為假則退出。循環(huán)體至少執(zhí)行一次,故會(huì)輸出de循環(huán)體以外的語句總會(huì)被執(zhí)行,故輸出f。givethecodefragment:switch(x){case1:system.out.println(test1);break;case2:case3:system.out.println(test2);break;default:system.out.println(end);}whichvalueofxwouldcausetest2totheoutput:123default6。b.c在開關(guān)語句中,標(biāo)號(hào)總是不被當(dāng)做語句的一部分,標(biāo)號(hào)的作用就是做為條件判斷而已,一旦匹配成功,就執(zhí)行其后的語句,一直遭遇break語句為止。(包括default語句在內(nèi))giveincompletedmethod:{if(unsafe()){//dosomething}elseif(safe()){//dotheother}}themethodunsafe()wellthroeanioexception,whichcompletesthemethodofdeclarationwhenaddedatlineone?publicioexceptionmethodname()publicvoidmethodname()publicvoidmethodname()throwioexceptionpublicvoidmethodname()throwsioexceptionpublicvoidmethodname()throwsexception7。d、fioexception異常類是exception的子類。根據(jù)多態(tài)性的定義,ioexception對(duì)象也可以被認(rèn)為是exception類型。還要注意在方法聲明中拋出異常應(yīng)用關(guān)鍵字throws。givethecodefragment:if(x4){system.out.println(test1);}elseif(x9){system.out.println(test2);}else{system.out.println(test3);}whichrangeofvaluexwouldproduceofoutputtest2?x4x4x9none8。d只有兩種情況:大于4時(shí)輸出test1,小于等于4時(shí)輸出test3。givethefollowingmethod:publicvoidexample(){try{unsafe();system.out.println(test1);}catch(safeexceptione){system.out.println(test2);}finally{system.out.println(test3);}system.out.println(test4);whichwilldisplayifmethodunsafe()runnormally?test1test2test3test49。a、c、d在正常情況下,打印testl、test3、test4;在產(chǎn)生可捕獲異常時(shí)打印test2、test3、test4;在產(chǎn)生不可捕獲異常時(shí),打印test3,然后終止程序。注意finally后面的語句總是被執(zhí)行。whichmethodyoudefineasthestartingpointofnewthreadinaclassfromwhichnewthethreadcanbeexcution?publicvoidstart()publicvoidrun()publicvoidint()publicstaticvoidmain(stringargs[])publicvoidrunnable()10。b線程的執(zhí)行是從方法run()開始的,該方法是由系統(tǒng)調(diào)用的。程序員手工調(diào)用方法start(),使線程變?yōu)榭蛇\(yùn)行狀態(tài)。giventhefollowingclassdefinition:classa{protectedinti;a(inti){this.i=i;}whichofthefollowingwouldbeavalidinnerclassforthisclass?selectallvalidanswers:classb{}classbextendsa{}classbextendsa{b(){system.out.println(i=+i);}}classb{classa{}}classa{}11。a此題考查內(nèi)部類及關(guān)鍵字super的用法。內(nèi)部類不能與外部類同名。另外,當(dāng)b繼承a時(shí),a中的構(gòu)造函數(shù)是帶參數(shù)的,b中缺省構(gòu)造函數(shù)的函數(shù)體為空;而Java編譯器會(huì)為空構(gòu)造函數(shù)體自動(dòng)添加語句super();調(diào)用父類構(gòu)造函數(shù),更進(jìn)一步是調(diào)用父類的參數(shù)為空的構(gòu)造函數(shù)。而父類中沒有參數(shù)為空的構(gòu)造函數(shù)。whichmodifiershouldbeappliedtoamethodforthelockofobjectthistobeobtainedpriortoexcutionanyofthemethodbody?synchronizedabstractfinalstaticpublic12。a此關(guān)鍵字可以在兩個(gè)線程同時(shí)試圖訪問某一數(shù)據(jù)時(shí)避免數(shù)據(jù)毀損。thefollowingcodeisentirecontentsofafilecalledexample.java,causespreciselyoneerrorduringcompilation:classsubclassextendsbaseclass{}classbaseclass(){stringstr;publicbaseclass(){system.out.println(ok);}publicbaseclass(strings){str=s;}}publicclassexample{publicvoidmethod(){subclasss=newsubclass(hello);baseclassb=newbaseclass(world);}}whichlinewouldbecausetheerror?a.9b.10c.11d.1213。c當(dāng)一個(gè)類中未顯式定義構(gòu)造函數(shù)時(shí)做省的構(gòu)造函數(shù)是以類名為函數(shù)名,參數(shù)為空,函數(shù)體為空。雖然父類中的某一構(gòu)造函數(shù)有字符串參數(shù)s,但是子類繼承父類時(shí)并不繼承構(gòu)造函數(shù),所以它只能使用缺省構(gòu)造函數(shù)。故在第11行出錯(cuò)。whichstatementiscorrectlydeclareavariableawhichissuitableforreferingtoanarrayof50stringemptyobject?string口astringa[]chara□口stringa[50]objecta[50]14。a、b注意,題中問的是如何正確聲明一個(gè)一維數(shù)組,并非實(shí)例化或者初始化數(shù)組givethefollowingjavasourcefragement://pointxpublicclassinteresting{//dosomething}whichstatementiscorrectlyjavasyntaxatpointx?importjava.awt.*;b.packagemypackagestaticintpi=3.14publicclassmyclass{//dootherthing}e.classmyclass{//dosomething}15。a、ex處可以是一個(gè)輸入,包的定義,類的定義。由于常量或變量的聲明只能在類中或方法中,故不能選擇 c;由于在一個(gè)文件中只能有一個(gè)public類,故不能選擇dogivethisclassoutline:classexample{privateintx;//restofclassbody}assumingthatxinvokedbythecodejavaexample,whichstatementcanmadexbedirectlyaccessibleinmain()methodofexample.java?changeprivateintxtopublicintxchangeprivateintxtostaticintxchangeprivateintxtoprotectedintxchangeprivateintxtofinalintx16。b靜態(tài)方法除了自己的參數(shù)外只能顛訪問靜態(tài)成員訪問非靜態(tài)成員,必須先實(shí)例化本類的一個(gè)實(shí)例,再用實(shí)例名點(diǎn)取。thepieceofpreliminaryanalsisworkdescribesaclassthatwillbeusedfrequentlyinmanyunrelatedpartsofaprojectthepolygonobjectisadrawable,apolygonhasvertexinformationstoredinavector,acolor,lengthandwidth.whichdatatypewouldbeused?vectorintstringcolordatea、b、dpolygon的頂點(diǎn)信息存放在vector類型的對(duì)象內(nèi)部,color定義為color,length和width定義為int。注意,這是考試中常見的題型。aclassdesignrequiresthatamembervariableshouldbeaccessibleonlybysamepackage,whichmodiferwordshouldbeused?protectedpublicnomodiferprivate18。c此題考點(diǎn)是高級(jí)訪問控制。請(qǐng)考生查閱高級(jí)訪問控制說明表格。whichdeclaresfornativemethodinajavaclasscorrected?publicnativevoidmethod(){}publicnativevoidmethod();publicnativemethod();publicvoidmethod(){native;}publicvoidnativemethod();19。bnative關(guān)鍵字指明是對(duì)本地方法的調(diào)用,在java中是只能訪問但不能寫的方法,它的位置在訪問權(quán)限修飾語的后面及返回值的前面。whichmodifershouldbeappliedtoadeclarationofaclassmembervariableforthevalueofvariabletoremain
constantafterthecreationoftheobject?20。final定義常量的方法是在變量定義前加final關(guān)鍵字whichisthemain()methodreturnofaapplication?a.stringb.bytec.chard.void21。dmain()方法沒有返回值,所以必須用 void修飾。main()方法的返回值不能任意修改。whichiscorrectedargumentofmain()methodofapplication?stringargsstringar[]charargs□口stringbufferarg[]22。bmain()方法的參數(shù)是字符串?dāng)?shù)組,參數(shù)名可以任意定義。appointmentstoreinatheemployeeobjectisaperson,anemployeehasappointmentstoreinavector,ahiredateandanumber
ofdependentshortanswer:useshorteststatementdeclareaclassofemployee.23。publicclassemployeeextendsperson這也是真實(shí)考試中常見的一種題型.這也是真實(shí)考試中常見的一種題型.要
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025w勞動(dòng)合同范本
- Module 3 Unit 3 Days of the week(教學(xué)設(shè)計(jì))-2023-2024學(xué)年牛津上海版(試用本)英語四年級(jí)下冊
- 中后期安全策劃
- 2025貸款購房抵押合同
- 觀察我們的身體(教學(xué)設(shè)計(jì)) 2024-2025學(xué)年二年級(jí)科學(xué)下冊教科版
- 小學(xué)防傳染病班會(huì)課件
- 創(chuàng)造宣言新課件
- 2025標(biāo)準(zhǔn)租賃合同模板
- 2024秋八年級(jí)數(shù)學(xué)上冊 第4章 實(shí)數(shù)4.1 平方根 1算術(shù)平方根教學(xué)實(shí)錄(新版)蘇科版
- Unit 1 A trip to the silk road-Marco Polo and the silk road教學(xué)設(shè)計(jì)2024-2025學(xué)年冀教版英語七年級(jí)下冊
- GB/T 26516-2011按摩精油
- GB 31603-2015食品安全國家標(biāo)準(zhǔn)食品接觸材料及制品生產(chǎn)通用衛(wèi)生規(guī)范
- GB 29415-2013耐火電纜槽盒
- 勞務(wù)投標(biāo)書技術(shù)標(biāo)
- DB13∕T 5480-2022 政務(wù)公開專區(qū)建設(shè)指南
- 健康照護(hù)教材課件匯總完整版ppt全套課件最全教學(xué)教程整本書電子教案全書教案課件合集
- (5年高職)商務(wù)談判教學(xué)課件全套電子教案匯總整本書課件最全教學(xué)教程完整版教案(最新)
- 嘉興華雯化工 - 201604
- 骨科手術(shù)學(xué)課件:髖及大腿的手術(shù)入路及部分手術(shù)介紹
- 冀教版七年級(jí)下冊數(shù)學(xué)課件 第8章 8.2.1 冪的乘方
- 橋梁線形與變形檢測檢測方法實(shí)施細(xì)則
評(píng)論
0/150
提交評(píng)論