欢迎来到天天文库
浏览记录
ID:38265018
大小:68.00 KB
页数:7页
时间:2019-06-07
《java基础测试》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、QUESTION1:Whichtwocauseacompilererror?(Choosetwo)ABA.float[]=newfloat(3);B.floatf2[]=newfloat[];C.float[]f1=newfloat[3];D.floatf3[]=newfloat[3];E.floatf5[]={1.0f,2.0f,2.0f};F.floatf4[]=newfloat[]{1.0f,2.0f,3.0f};QUESTION2:Given:11.inti=1,j=10;12.do{13.if(
2、i++>--j){14.continue;15.}16.}while(i<5);System.out.println("i="+i+"andj="+j);Whatistheresult?DA.i=6andj=5B.i=5andj=5C.i=6andj=5D.i=5andj=6E.i=6andj=6QUESTION3:Given:11.inti=1,j=10;12.do{13.if(i>j){14.break;15.}16.j--;17.}while(++i<5);18.System.out.println
3、("i="+i+"andj="+j);Whatistheresult?DA.i=6andj=5B.i=5andj=5C.i=6andj=4D.i=5andj=6E.i=6andj=6QUESTION4:Given:11.intx=3;12.inty=1;13.if(x=y){14.System.out.println("x="+x);15.}Whatistheresult?CA.x=1B.x=3C.Compilationfails.D.Thecoderunswithnooutput.E.Anexcepti
4、onisthrownatruntime.QUESTION5:Given:1.publicclassDelta{2.staticbooleanfoo(charc){3.System.out.print(c);4.returntrue;5.}6.publicstaticvoidmain(String[]argv){7.inti=0;8.for(foo('A');foo('B')&&(i<2);foo('C')){9.i++;10.foo('D');12.}13.}14.}Whatistheresult?AA.
5、ABDCBDCBB.ABCDABCDC.Compilationfails.D.Anexceptionisthrownatruntime.QUESTION6:1.publicclassArrayTest{2.publicstaticvoidmain(String[]args){3.floatfl[],f2[];4.fl=newfloat[10];5.f2=f1;6.System.out.println("f2[0]="+f2[0]);7.}8.}Whatistheresult?CA.Itprintsf2[0
6、]=0.0.B.Itprintsf2[0]=NaN.C.Anerroratline5causescompiletofail.D.Anerroratline6causescompiletofail.E.Anerroratline6causesanexpectationatruntime.QUESTION7:publicclassPerson{publicintaMethod(){staticinti=0;i++;returni;}publicstaticvoidmain(Stringargs[]){Pers
7、ontest=newPerson();test.aMethod();intj=test.aMethod();System.out.println(j);}}Whatistheresult?DA.0B.1C.2D.Compilationfails.QUESTION8:Given:publicclassPerson{publicintaMethod(){staticinti=0;i++;returni;}publicstaticvoidmain(Stringargs[]){Persontest=newPers
8、on();test.aMethod();intj=test.aMethod();System.out.println(j);}}Whatistheresult?DA.j=-1B.j=0C.j=1D.j=2E.Compilationfails.QUESTION9:Given:booleanbool=true;if(bool=false){System.out.println("a");}elseif(bool){System.o
此文档下载收益归作者所有