欢迎来到天天文库
浏览记录
ID:10202714
大小:101.50 KB
页数:28页
时间:2018-06-12
《java基础练习题27875》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、Java基础练习题Question1.35.String#name=“JaneDoe”;36.int$age=24;37.Double_height=123.5;38.double~temp=37.5;Whichtwoaretrue?(Choosetwo.)A.Line35willnotcompile.B.Line36willnotcompile.C.Line37willnotcompile.D.Line38willnotcompile.//由字母,数字,下划线,美元符号组成,不能由数字开头Questio
2、n2.11.publicclassTest{12.publicstaticvoidmain(String[]args){13.intx=5;14.booleanb1=true;15.booleanb2=false;16.17.if((x==4)&&!b2)18.System.out.print(”l“);19.System.out.print(”2“);20.if((b2=true)&&b1)21.System.out.print(”3“);22.}23.}Whatistheresult?A.2B.3C.
3、12D.23E.123F.Compilationfails.G.Auexceptionalisthrownatruntime.Question3.42.publicclassClassA{43.publicintgetValue(){44.intvalue=0;45.booleansetting=true;46.Stringtitle=”Hello”;47.if(value
4、
5、(setting&&title==“Hello”)){return1;}48.if(value==1&title.equals(”
6、Hello”)){return2;}49.}50.}And:70.ClassAa=newClassA();71.a.getValue();Whatistheresult?A.1B.2C.Compilationfails.//最后缺少一个返回值D.Thecoderunswithnooutput.E.Anexceptionisthrownatruntime.Question1.35.intx=10;36.do{37.x--;38.}while(x<10);Howmanytimeswillline37beexe
7、cuted?A.tentimesB.zerotimesC.onetometimesD.morethantentimesQuestion2.11.publicstaticvoidmain(String[]args){12.Objectobj=newint[]{1,2,3};13.int[]someArray=(int[])obj;14.for(inti:someArray)System.out.print(i+““)15.}‘Whatistheresult?A.123B.Compilationfailsbe
8、causeofanerrorinline12.C.Compilationfailsbecauseofanerrorinline13.D.Compilationfailsbecauseofanerrorinline14.E.AClassCastExceptionisthrownatruntime.Question3.Aprogrammerneedstocreatealoggingmethodthatcanacceptanarbitrarynumberofarguments.Forexample,itmayb
9、ecalledintheseways:logIt(”logmessage1“);logIt(”logmessage2”,”logmessage3”);logIt(”logmessage4”,“logmessage5”,“logmessage6);Whichdeclarationsatisfiesthisrequirement?A.publicvoidlogIt(String*msgs)B.publicvoidlogIt(String[]msgs)C.publicvoidlogIt(String...msg
10、s)D.publicvoidlogIt(Stringmsg1,Stringmsg2,Stringmsg3)Question1.ClicktheExhibitbutton.1.publicclassA{2.publicStringdoit(intx,inty){3.return“a”;4.}5.6.publicStringdoit(int...vals){7.return“b”;8.}9.}Given:25.Aa=newA();
此文档下载收益归作者所有