



版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、姓名:_ 班級(jí):_ 學(xué)號(hào):_-密-封 -線- java題庫(kù):格林模擬試題二(上)考試時(shí)間:120分鐘 考試總分:100分題號(hào)一二三四五總分分?jǐn)?shù)遵守考場(chǎng)紀(jì)律,維護(hù)知識(shí)尊嚴(yán),杜絕違紀(jì)行為,確??荚嚱Y(jié)果公正。question1) whatwillhappenwhenyouattempttocompileandrunthiscode? abstractclassbaseabstractpublicvoidmyfunc();publicvoidanother()system.out.println(“anothermethod”);publicclassabsextendsbasepublicstati
2、cvoidmain(stringargv)absa=newabs();a.amethod();publicvoidmyfunc()system.out.println(“myfunc”);publicvoidamethod()myfunc(); 1)thecodewillcompileandrun,printingoutthewords”myfunc” 2)thecompilerwillcomplainthatthebaseclasshasnonabstractmethods 3)thecodewillcompilebutcomplainatruntimethatthebaseclasshas
3、nonabstractmethods 4)thecompilerwillcomplainthatthemethodmyfuncinthebaseclasshasnobody,nobodyatalltoloooveit question2) whatwillhappenwhenyouattempttocompileandrunthiscode? publicclassmymainpublicstaticvoidmain(stringargv)system.out.println(“hellocruelworld”); 1)thecompilerwillcomplainthatmainisares
4、ervedwordandcannotbeusedforaclass 2)thecodewillcompileandwhenrunwillprintout”hellocruelworld” 3)thecodewillcompilebutwillcomplainatruntimethatnoconstructorisdefined 4)thecodewillcompilebutwillcomplainatruntimethatmainisnotcorrectlydefined question3) whichofthefollowingarejavamodifiers? 1)public 2)pr
5、ivate 3)friendly 4)transient 5)vagrant question4) whatwillhappenwhenyouattempttocompileandrunthiscode? classbaseabstractpublicvoidmyfunc();publicvoidanother()system.out.println(“anothermethod”);publicclassabsextendsbasepublicstaticvoidmain(stringargv)absa=newabs();a.amethod();publicvoidmyfunc()syste
6、m.out.println(“myfunc”);publicvoidamethod()myfunc(); 1)thecodewillcompileandrun,printingoutthewords”myfunc” 2)thecompilerwillcomplainthatthebaseclassisnotdeclaredasabstract. 3)thecodewillcompilebutcomplainatruntimethatthebaseclasshasnonabstractmethods 4)thecompilerwillcomplainthatthemethodmyfuncinth
7、ebaseclasshasnobody,nobodyatalltoloooveit question5) whymightyoudefineamethodasnative? 1)togettoaccesshardwarethatjavadoesnotknowabout 2)todefineanewdatatypesuchasanunsignedinteger 3)towriteoptimisedcodeforperformanceinalanguagesuchasc/c+ 4)toovercomethelimitationoftheprivatescopeofamethod question6
8、) whatwillhappenwhenyouattempttocompileandrunthiscode? classbasepublicfinalvoidamethod()system.out.println(“amethod”);publicclassfinextendsbasepublicstaticvoidmain(stringargv)baseb=newbase();b.amethod(); 1)compiletimeerrorindicatingthataclasswithanyfinalmethodsmustbedeclaredfinalitself 2)compiletime
9、errorindicatingthatyoucannotinheritfromaclasswithfinalmethods 3)runtimeerrorindicatingthatbaseisnotdefinedasfinal 4)successincompilationandoutputof”amethod”atruntime. question7) whatwillhappenwhenyouattempttocompileandrunthiscode? publicclassmodpublicstaticvoidmain(stringargv)publicstaticnativevoida
10、method(); 1)erroratcompilation:nativemethodcannotbestatic 2)erroratcompilationnativemethodmustreturnvalue 3)compilationbuterroratruntimeunlessyouhavemadecodecontainingnativeamethodavailable 4)compilationandexecutionwithouterror question8) whatwillhappenwhenyouattempttocompileandrunthiscode? privatec
11、lassbasepublicclassvistransientintival;publicstaticvoidmain(stringelephant) 1)compiletimeerror:basecannotbeprivate 2)compiletimeerrorindicatingthatanintegercannotbetransient 3)compiletimeerrortransientnotadatatype 4)compiletimeerrormalformedmainmethod question9) whathappenswhenyouattempttocompileand
12、runthesetwofilesinthesamedirectory? /filep1.javapackagemypackage;classp1voidafancymethod()system.out.println(“whatafancymethod”);/filep2.javapublicclassp2extendsp1publicstaticvoidmain(stringargv)p2p2=newp2();p2.afancymethod(); 1)bothcompileandp2outputs”whatafancymethod”whenrun 2)neitherwillcompile 3
13、)bothcompilebutp2hasanerroratruntime 4)p1compilescleanlybutp2hasanerroratcompiletime question10) youwanttofindoutthevalueofthelastelementofanarray.youwritethefollowingcode.whatwillhappenwhenyoucompileandrunit.? publicclassmyarpublicstaticvoidmain(stringargv)inti=newint;system.out.println(i); 1)anerr
14、oratcompiletime 2)anerroratruntime 3)thevalue0willbeoutput 4)thestring”null”willbeoutput question11) youwanttoloopthroughanarrayandstopwhenyoucometothelastelement.beingagoodjavaprogrammerandforgettingeverythingyoueverknewaboutc/c+youknowthatarrayscontaininformationabouttheirsize.whichofthefollowingc
15、anyouuse? 1)myarray.length(); 2)myarray.length; 3)myarray.size 4)myarray.size(); question12) whatbestdescribestheappearanceofanapplicationwiththefollowingcode? importjava.awt.*;publicclassflowapextendsframepublicstaticvoidmain(stringargv)flowapfa=newflowap();fa.setsize(400,300);fa.setvisible(true);f
16、lowap()add(newbutton(“one”);add(newbutton(“two”);add(newbutton(“three”);add(newbutton(“four”);/endofconstructor/endofapplication 1)aframewithbuttonsmarkedonetofourplacedoneachedge. 2)aframewithbuutonsmarkedonetofourrunningfromthetoptobottom 3)aframewithonelargebuttonmarkedfourinthecentre 4)anerrorat
17、runtimeindicatingyouhavenotsetalayoutmanager question13) howdoyouindicatewhereacomponentwillbepositionedusingflowlayout? 1)north,south,east,west 2)assignarow/columngridreference 3)passax/ypercentageparametertotheaddmethod 4)donothing,theflowlayoutwillpositionthecomponent question14) howdoyouchangeth
18、ecurrentlayoutmanagerforacontainer 1)usethesetlayoutmethod 2)oncecreatedyoucannotchangethecurrentlayoutmanagerofacomponent 3)usethesetlayoutmanagermethod 4)usetheupdatelayoutmethod question15) whichofthefollowingarefieldsofthegridbagconstraintsclass? 1)ipadx 2)fill 3)insets 4)width question16) whatm
19、ostcloselymatchestheappearancewhenthiscoderuns? importjava.awt.*;publicclasscomplayextendsframepublicstaticvoidmain(stringargv)complaycl=newcomplay();complay()panelp=newpanel();p.setbackground(color.pink);p.add(newbutton(“one”);p.add(l3)thebuttonswillnotbedisplayed 4)onlybuttonthreewillshowoccupying
20、alloftheframe question17) whichstatementsarecorrectabouttheanchorfield? 1)itisafieldofthegridbaglayoutmanagerforcontrollingcomponentplacement 2)itisafieldofthegridbagconstraintsclassforcontrollingcomponentplacement 3)avalidsettingfortheanchorfieldisgridbagconstraints.north 4)theanchorfieldcontrolsth
21、eheightofcomponentsaddedtoacontainer question18) whatwillhappenwhenyouattempttocompileandrunthefollowingcode? publicclassbgroundextendsthreadpublicstaticvoidmain(stringargv)bgroundb=newbground();b.run();publicvoidstart()for(inti=0;i10;i+)system.out.println(“valueofi=“+i); 1)acompiletimeerrorindicati
22、ngthatnorunmethodisdefinedforthethreadclass 2)aruntimeerrorindicatingthatnorunmethodisdefinedforthethreadclass 3)cleancompileandatruntimethevalues0to9areprintedout 4)cleancompilebutnooutputatruntime question19) isthefollowingstatementtrueorfalse? whenusingthegridbaglayoutmanager,eachnewcomponentrequ
23、iresanewinstanceofthegridbagconstraintsclass. 1)true 2)false question20) whichmostcloselymatchesadescriptionofajavamap? 1)avectorofarraysfora2dgeographicrepresentation 2)aclassforcontaininguniquearrayelements 3)aclassforcontaininguniquevectorelements 4)aninterfacethatensuresthatimplementingclassesca
24、nnotcontainduplicatekeys question21) howdoesthesetcollectiondealwithduplicateelements? 1)anexceptionisthrownifyouattempttoaddanelementwithaduplicatevalue 2)theaddmethodreturnsfalseifyouattempttoaddanelementwithaduplicatevalue 3)asetmaycontainelementsthatreturnduplicatevaluesfromacalltotheequalsmetho
25、d 4)duplicatevalueswillcauseanerroratcompiletime question22) whatcancauseathreadtostopexecuting? 1)theprogramexitsviaacalltosystem.exit(0); 2)anotherthreadisgivenahigherpriority 3)acalltothethreadsstopmethod. 4)acalltothehaltmethodofthethreadclassquestion23) foraclassdefinedinsideamethod,whatrulegov
26、ernsaccesstothevariablesoftheenclosingmethod? 1)theclasscanaccessanyvariable 2)theclasscanonlyaccessstaticvariables 3)theclasscanonlyaccesstransientvariables 4)theclasscanonlyaccessfinalvariables question24) underwhatcircumstancesmightyouusetheyieldmethodofthethreadclass 1)tocallfromthecurrentlyrunn
27、ingthreadtoallowanotherthreadofthesameorhigherprioritytorun 2)tocallonawaitingthreadtoallowittorun 3)toallowathreadofhigherprioritytorun 4)tocallfromthecurrentlyrunningthreadwithaparameterdesignatingwhichthreadshouldbeallowedtorun question25) whatwillhappenwhenyouattempttocompileandrunthefollowingco
28、de publicclasshopepublicstaticvoidmain(stringargv)hopeh=newhope();protectedhope()for(inti=0;i10;i+)system.out.println(i); 1)compilationerror:constructorscannotbedeclaredprotected 2)runtimeerror:constructorscannotbedeclaredprotected 3)compilationandrunningwithoutput0to10 4)compilationandrunningwithou
29、tput0to9 question26) whatwillhappenwhenyouattempttocompileandrunthefollowingcode publicclassmyswitchpublicstaticvoidmain(stringargv)myswitchms=newmyswitch();ms.amethod();publicvoidamethod()intk=10;switch(k)default:/putthedefaultatthebottom,notheresystem.out.println(“thisisthedefaultoutput”);break;ca
30、se10:system.out.println(“ten”);case20:system.out.println(“twenty”);break; 1)noneoftheseoptions 2)compiletimeerrortargetofswitchmustbeanintegraltype 3)compileandrunwithoutput”thisisthedefaultoutput” 4)compileandrunwithoutputofthesingleline”ten” question22) whatcancauseathreadtostopexecuting? 1)thepro
31、gramexitsviaacalltosystem.exit(0); 2)anotherthreadisgivenahigherpriority 3)acalltothethreadsstopmethod. 4)acalltothehaltmethodofthethreadclassquestion23) foraclassdefinedinsideamethod,whatrulegovernsaccesstothevariablesoftheenclosingmethod? 1)theclasscanaccessanyvariable 2)theclasscanonlyaccessstati
32、cvariables 3)theclasscanonlyaccesstransientvariables 4)theclasscanonlyaccessfinalvariables question24) underwhatcircumstancesmightyouusetheyieldmethodofthethreadclass 1)tocallfromthecurrentlyrunningthreadtoallowanotherthreadofthesameorhigherprioritytorun 2)tocallonawaitingthreadtoallowittorun 3)toal
33、lowathreadofhigherprioritytorun 4)tocallfromthecurrentlyrunningthreadwithaparameterdesignatingwhichthreadshouldbeallowedtorun question25) whatwillhappenwhenyouattempttocompileandrunthefollowingcode publicclasshopepublicstaticvoidmain(stringargv)hopeh=newhope();protectedhope()for(inti=0;i10;i+)system
34、.out.println(i); 1)compilationerror:constructorscannotbedeclaredprotected 2)runtimeerror:constructorscannotbedeclaredprotected 3)compilationandrunningwithoutput0to10 4)compilationandrunningwithoutput0to9 question26) whatwillhappenwhenyouattempttocompileandrunthefollowingcode publicclassmyswitchpubli
35、cstaticvoidmain(stringargv)myswitchms=newmyswitch();ms.amethod();publicvoidamethod()intk=10;switch(k)default:/putthedefaultatthebottom,notheresystem.out.println(“thisisthedefaultoutput”);break;case10:system.out.println(“ten”);case20:system.out.println(“twenty”);break; 1)noneoftheseoptions 2)compiletimeerrortargetofswitchmustbeanintegraltype 3)compileandrunwithoutput”thisisthedefaultoutput” 4)compileandrunwithoutputofthesingleline”ten” question27) whichofthefollowingisthecorrectsyntaxforsuggestingthatthejvmperformsgarbagecollection 1)system.free(); 2)system.setgarbagecollection(); 3)syste
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 和聲中的典型模式與變化樂理試題及答案
- 多元化數(shù)學(xué)學(xué)習(xí)試題及答案
- 學(xué)習(xí)數(shù)學(xué)測(cè)試試題及答案
- 大學(xué)化學(xué)學(xué)習(xí)共享資源平臺(tái)的建設(shè)試題及答案
- 美術(shù)藝術(shù)試題庫(kù)及答案
- 外貌特點(diǎn)測(cè)試題及答案
- 新能源汽車技術(shù)推廣的關(guān)鍵因素試題及答案
- 停車優(yōu)惠券合同范例
- 化學(xué)實(shí)驗(yàn)安全知識(shí)試題及答案
- 小學(xué)教材面試題及答案
- 2025年形勢(shì)與政策-加快建設(shè)社會(huì)主義文化強(qiáng)國(guó)+第二講中國(guó)經(jīng)濟(jì)行穩(wěn)致遠(yuǎn)
- 汽車維修服務(wù)客戶滿意度提升流程
- 2024人教版七年級(jí)下冊(cè)生物第三單元 植物的生活 單元測(cè)試卷(含答案)
- 氣象防災(zāi)減災(zāi)知識(shí)科普
- 中國(guó)慢性冠脈綜合征患者診斷及管理指南2024版解讀
- 廣西田林八渡金礦 資源儲(chǔ)量核實(shí)報(bào)告
- 心梗的預(yù)防指南
- 運(yùn)維人員管理方案
- 基于深度學(xué)習(xí)的電力系統(tǒng)故障恢復(fù)與優(yōu)化方法研究
- 四川省德陽(yáng)市(2024年-2025年小學(xué)六年級(jí)語(yǔ)文)統(tǒng)編版小升初模擬((上下)學(xué)期)試卷及答案
- 2025年中考語(yǔ)文文學(xué)作品閱讀-人物形象(解析版)
評(píng)論
0/150
提交評(píng)論