資源描述:
《JAVA_經(jīng)典_基礎(chǔ)試題》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫(kù)。
1、JAVA基礎(chǔ)考試題(請(qǐng)勿在此卷上填寫(xiě)答案,請(qǐng)將答案寫(xiě)在答題卡上,考試時(shí)間90分鐘,總分102分)一、選擇題(每題2分,共42分;錯(cuò)選不給分;少選給1分)1====1.publicclasstest{2.publicstaticvoidmain(Stringargs[]){3.inti=5;4.intj=i<<2;5.6.}7.}Whatisthedecimalvalueofjatline5?A.0B.1C.20D.-15E.Anerroratline3causescompilationtofail.F.Anerroratline4causescompilationtofail.2====
2、Integeri=newInteger(42);Longl=newLong(42);Doubled=newDouble(42.0);WhichexpressionsevaluatetoTrue?A.(i==l)B.(i==d)C.(d==l)D.(i.equals(d))E.(d.equals(i))F.(i.equals(42))G.None3====1.publicclasstest{2.privatestaticintj=0;3.4.privatestaticbooleanmethodB(intk){5.j+=k;6.returntrue;7.}8.9.publicstaticvo
3、idmethodA(inti){10.booleanb:11.b=i<10
4、methodB(4);12.b=i<10
5、
6、methodB(8);13.}14.15.publicstaticvoidmain(Stringargs[]){16.methodA(0);17.System.out.println(j);18.}819.}Whatistheresult?A.Theprogramprints"0"B.Theprogramprints"4"C.Theprogramprints"8"D.Theprogramprints"12"E.Thecodedoesnotcomplete4====1.p
7、ublicclassFoo{2.publicstaticvoidmain(String[]args){3.StringBuffera=newStringBuffer("A");4.StringBufferb=newStringBuffer("B");5.operate(a,b);6.system.out.println(a+","+b);7.}8.staticvoidoperate(StringBufferx,StringBuffery){9.x.append(y);10.y=x;11.}12.}Whatistheresult?A.Thecodecompilesandprints"A,B
8、".B.Thecodecompilesandprints"A,A".C.Thecodecompilesandprints"B,B".D.Thecodecompilesandprints"AB,B".E.Thecodecompilesandprints"AB,AB".F.Thecodedoesnotcompilebecause"+"cannotbeoverloadedforStringBuffer.5====1.publicclasstest{2.publicstaticvoidadd3(Integeri){3.intval=i.intValue();4.val+=3;5.i=newInt
9、eger(val);6.}7.8.publicstaticvoidmain(Stringargs[]){9.Integeri=newInteger(0);10.add3(i);11.System.out.println(i.intValue());12.}13.}Whatistheresult?A.Compilationwillfail.B.Theprogramprints"0".C.Theprogramprints"3".D.Compilationwillsucceedbutanexceptionwillbethrownatline3.6====1.publicclassConstOv
10、er{2.publicConstOver(intx,inty,intz){83.}4.}WhichtwooverloadtheConstOverconstructor?(ChooseTwo)A.ConstOver(){}B.protectedintConstOver(){}C.privateConstOver(bytex,bytey,bytez){}D.publicObjectConstOver(intx,inty,intz){}E