资源描述:
《java选择题(java multiple-choice questions)》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、java选择题(Javamultiple-choicequestions)49.givethefollowingcodetoaskwhichstatementisinsertedinthetenthlineoftheprogram,andtheprogramcanrunsuccessfullyLine1.classIntTypeLine2.publicStringgetType(Stringa,intb,charc){Line3.Stringholdit1=newString();Line4.holdit1=a;L
2、ine5.returnholdit1;Line6.}Line7.}Line8.Line9.classOverTypeextendsIntType{Line10.Line11.Stringholdit2=newString();Line12.holdit2=holdit2.concat("Thisis").Concat(a);Line13.returnholdit2;Line14.}Line15.Line16.publicstaticvoidmain(String[]a){Line17.OverTypeot=newO
3、verType();Line18.Stringx=newString("X");Line19.inty=1;Line20.charz='b';Line21.System.out.println(getType(x,y,z));Line22.}Line23.}Pleaseselectallthecorrectanswers:(1)publicTextgetType(Stringa,intb,charc){(2)publicTextgetType(intb,Stringa,charc){(3)publicStringg
4、etType(Stringa,intb,charc){(4)publicStringgetType(intb,Stringa,charc){50.whichstatementsareusedinJavalanguageforinterruptcycleexecution?Pleasechooseacorrectanswer:(1)continuestatement(2)gotostatement(3)exitstatement(4)breakstatement51.excuseme,whereisthewrongc
5、odebelow?PublicclassExample{Publicstaticvoidmain(String[]args){For(i=0;j=0,i<10;++i,j+=i){K+=i*i+j*j;}}}Pleaseselectallthecorrectanswers:(1)morethanonesentenceshouldbemorethanonesentenceblock(2)commashouldbeusedbetweeni=0andj=0(3)twocircularvariablesareused(4)
6、semicolonshouldbeusedbetweenj=0andi<1052.excuseme,whereisthefollowingcodefragmentwrong?For(inti=0;i<10;++i){If(x[i]>100)break;If(x[i]<0)continue;X[i+1]=x[i]+y[i];}Pleasechooseacorrectanswer:(1)itisillegaltoappearbothbreakandcontinuestatementsinthesameforloopst
7、atement(2)thevariableIshouldnotbedeclaredandinitializedintheforexpression(3)automaticincrementoperationisnotallowedintheforexpression(4)nothingwrong53.givethefollowingcode,whatistherunningresultofthisprogram?PublicclassExample{Publicstaticvoidmain(String[]args
8、){Intm=2;Intp=1;Intt=0;For((p<5;p++){If(t++>m){M=p+t;}}System.out.println("tequals"+t);}}Pleasechooseacorrectanswer:(1)tequals2(2)tequals4(3)tequals6(4)tequals754.givethefollowingc