欢迎来到天天文库
浏览记录
ID:37925948
大小:78.00 KB
页数:8页
时间:2019-06-02
《JAVA_经典_基础试题》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、JAVA基础考试题(请勿在此卷上填写答案,请将答案写在答题卡上,考试时间90分钟,总分102分)一、选择题(每题2分,共42分;错选不给分;少选给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
此文档下载收益归作者所有