




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
iiiitheprogrammerhasamechanismthatexplicityandimmediatelyfreesthememoryusedbyjavaobjects.thegarbagecollectionmechanismcanfreethememoryusedbyjavaobjectatexplectiontime.thegarbagecollectionsystemneverreclaimsmemoryfromobjectswhilearestillaccessibletorunninguserthreads.1。b、ejava的垃圾回收機制是通過一個后臺系統(tǒng)級線程對內(nèi)存分配情況進(jìn)行跟蹤實現(xiàn)的,對程序員來說是透明的,程序員沒有任何方式使無用內(nèi)存顯示的、立即的被釋放。而且它是在程序運行期間發(fā)生的。答案b告訴我們程序員可以使一個本地變量失去任何意義,例如給本地變量賦值為null;答案e告訴我們在程序運行期間不可能完全釋放內(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)存空間就失去了作用,它可能被釋放。所以對象a可能最早被垃圾回收是在第7行以前,故選擇d選項。intheclassjava.awt.awtevent,whichistheparentclassuponwhichjdkl.1awteventsarebasedthereisamethodcalledgetidwhichphraseaccuratelydescribesthereturnvalueofthismethod?hecaseofamouseclick,itisanindicationofthetextunderthemouseatthetimeoftheevent.ittellsthestateofcertainkeysonthekeybordatthetimeoftheevent.itisanindicationofthetimeatwhichtheeventoccurred.3。b請查閱java類庫。getid方法的返回值是eventtype。在認(rèn)證考試中,總會有類似的書本以外的知識,這只能靠多實踐來增長知識了。whichstatementaboutlisteneristrue?mostcomponentallowmultiplelistenerstobeadded.ifmultiplelistenerbeaddtoasinglecomponent,theeventonlyaffectedoneponentdon?tallowmultiplelistenerstobeadd.thelistenermechanismallowsyoutocallanaddxxxxlistenermethodasmanytimesasisneeded,specifyingasmanydifferentlistenersasyourdesignrequire.4。a、d控件可以同時使用多個addxxxxlistener方法加入多個監(jiān)聽器。并且當(dāng)多個監(jiān)聽器加入到同一控件中時,事件可以響應(yīng)多個監(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本題主要考察考生對流程控制的掌握情況。這是當(dāng)型循環(huán),條件為真執(zhí)行,條件為假則退出。循環(huán)體至少執(zhí)行一次,故會輸出de循環(huán)體以外的語句總會被執(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)號總是不被當(dāng)做語句的一部分,標(biā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對象也可以被認(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時輸出test1,小于等于4時輸出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)生可捕獲異常時打印test2、test3、test4;在產(chǎn)生不可捕獲異常時,打印test3,然后終止程序。注意finally后面的語句總是被執(zhí)行。whichmethodyoudefineasthestartingpointofnewthreadinaclassfromwhichnewthethreadcanbeexcution?publicvoidstart()publicvoidrun()publicvoidint()publicstaticvoidmain(stringargs[])publicvoidrunnable()10。b線程的執(zhí)行是從方法run()開始的,該方法是由系統(tǒng)調(diào)用的。程序員手工調(diào)用方法start(),使線程變?yōu)榭蛇\行狀態(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時,a中的構(gòu)造函數(shù)是帶參數(shù)的,b中缺省構(gòu)造函數(shù)的函數(shù)體為空;而Java編譯器會為空構(gòu)造函數(shù)體自動添加語句super();調(diào)用父類構(gòu)造函數(shù),更進(jìn)一步是調(diào)用父類的參數(shù)為空的構(gòu)造函數(shù)。而父類中沒有參數(shù)為空的構(gòu)造函數(shù)。whichmodifiershouldbeappliedtoamethodforthelockofobjectthistobeobtainedpriortoexcutionanyofthemethodbody?synchronizedabstractfinalstaticpublic12。a此關(guān)鍵字可以在兩個線程同時試圖訪問某一數(shù)據(jù)時避免數(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òu)造函數(shù)時做省的構(gòu)造函數(shù)是以類名為函數(shù)名,參數(shù)為空,函數(shù)體為空。雖然父類中的某一構(gòu)造函數(shù)有字符串參數(shù)s,但是子類繼承父類時并不繼承構(gòu)造函數(shù),所以它只能使用缺省構(gòu)造函數(shù)。故在第11行出錯。whichstatementiscorrectlydeclareavariableawhichissuitableforreferingtoanarrayof50stringemptyobject?string口astringa[]chara□口stringa[50]objecta[50]14。a、b注意,題中問的是如何正確聲明一個一維數(shù)組,并非實例化或者初始化數(shù)組givethefollowingjavasourcefragement://pointxpublicclassinteresting{//dosomething}whichstatementiscorrectlyjavasyntaxatpointx?importjava.awt.*;b.packagemypackagestaticintpi=3.14publicclassmyclass{//dootherthing}e.classmyclass{//dosomething}15。a、ex處可以是一個輸入,包的定義,類的定義。由于常量或變量的聲明只能在類中或方法中,故不能選擇 c;由于在一個文件中只能有一個public類,故不能選擇dogivethisclassoutline:classexample{privateintx;//restofclassbody}assumingthatxinvokedbythecodejavaexample,whichstatementcanmadexbedirectlyaccessibleinmain()methodofexample.java?changeprivateintxtopublicintxchangeprivateintxtostaticintxchangeprivateintxtoprotectedintxchangeprivateintxtofinalintx16。b靜態(tài)方法除了自己的參數(shù)外只能顛訪問靜態(tài)成員訪問非靜態(tài)成員,必須先實例化本類的一個實例,再用實例名點取。thepieceofpreliminaryanalsisworkdescribesaclassthatwillbeusedfrequentlyinmanyunrelatedpartsofaprojectthepolygonobjectisadrawable,apolygonhasvertexinformationstoredinavector,acolor,lengthandwidth.whichdatatypewouldbeused?vectorintstringcolordatea、b、dpolygon的頂點信息存放在vector類型的對象內(nèi)部,color定義為color,length和width定義為int。注意,這是考試中常見的題型。aclassdesignrequiresthatamembervariableshouldbeaccessibleonlybysamepackage,whichmodiferwordshouldbeused?protectedpublicnomodiferprivate18。c此題考點是高級訪問控制。請考生查閱高級訪問控制說明表格。whichdeclaresfornativemethodinajavaclasscorrected?publicnativevoidmethod(){}publicnativevoidmethod();publicnativemethod();publicvoidmethod(){native;}publicvoidnativemethod();19。bnative關(guān)鍵字指明是對本地方法的調(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這也是真實考試中常見的一種題型.這也是真實考試中常見的一種題型.要
溫馨提示
- 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)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 軟件升級及維護(hù)合同
- 交通協(xié)管員聘用合同協(xié)議書
- 家禽購銷合同
- 貨品抵款結(jié)算協(xié)議書
- 應(yīng)對市場變化的解決方案研究
- 蘭州房屋租賃合同
- 機械租賃協(xié)議合同
- 第19課 治學(xué)須有疑無疑不成學(xué)-《懷疑與學(xué)問》(教學(xué)設(shè)計)九年級語文上冊同步高效課堂(統(tǒng)編版)
- 第一單元學(xué)習(xí)任務(wù)《如何闡述自己的觀點》教學(xué)設(shè)計 2023-2024學(xué)年統(tǒng)編版高中語文必修下冊
- Unit 4 Fun with numbers 第二課時(教學(xué)設(shè)計)-2024-2025學(xué)年外研版(三起)(2024)英語三年級上冊
- 班級公約(完美版)
- 第六章ACS6000勵磁單元
- 醫(yī)療衛(wèi)生監(jiān)督協(xié)管巡查記錄表
- 水利工程資料匯編全套
- 教科版科學(xué)四年級下冊第一單元《植物的生長變化》單元作業(yè)設(shè)計
- 中國交建模板
- 《寒假開學(xué)第一課》課件
- 三年級數(shù)學(xué)研課標(biāo)說教材課件
- 校園食品安全培訓(xùn)ppt課件(圖文)
- 卡通開學(xué)季安全教育幼兒開學(xué)第一課小學(xué)一二三年級PPT通用模板開學(xué)第一課安全教育主題課件開學(xué)第一課安全主題班會
- 北師大版四年級書法練習(xí)指導(dǎo)下冊全冊課件【完整版】
評論
0/150
提交評論