资源预览内容
第1页 / 共34页
第2页 / 共34页
第3页 / 共34页
第4页 / 共34页
第5页 / 共34页
第6页 / 共34页
第7页 / 共34页
第8页 / 共34页
第9页 / 共34页
第10页 / 共34页
亲,该文档总共34页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
在线考试 本次考试得分:96.0 1.(单选题)下列代码的运行结果是:01publicclassGoTest 02publicstaticvoidmain(String args) 03Sente a =newSente();04a.go();05Goban b =newGoban();06b.go();07Stone c =newStone();08c.go();091011classSenteimplementsGo 12publicvoidgo() 13System.out.println(go in Sente);141516classGobanextendsSente 17publicvoidgo() 18System.out.println(go in Goban);192021classStoneextendsGobanimplementsGo 2223interfaceGo 24publicvoidgo();25o A.go in Goban go in Sente go in Senteo B.go in Sente go in Sente go in Gobano C.go in Sente go in Goban go in Gobano D.go in Goban go in Goban go in Sente正确答案:C解析: 2.(单选题)请看下列代码:01classPayload 02privateintweight;03publicPayload(intwt) 04weight = wt;0506publicPayload() 07publicvoidsetWeight(intw) 08weight = w;0910publicString toString() 11returnInteger.toString(weight);121314publicclassTestPayload 15staticvoidchangePayload(Payload p) 161718publicstaticvoidmain(String args) 19Payload p =newPayload();20p.setWeight(1024);21changePayload(p);22System.out.println(The value of p is + p);2324假设运行后输出“The value of p is 420”,那么处应填入代码是:o A.p.setWeight(420);o B.Payload.setWeight(420);o C.p = new Payload(420);o D.p = new Payload(); p.setWeight(420);正确答案:A解析: 3.(单选题)关于下列代码说法不正确的是:0110.interfaceFoo 0211.intbar();0312. 0413.0514.publicclassBeta 0615.0716.classAimplementsFoo 0817.publicintbar() return1; 0918. 1019.1120.publicintfubar( Foo foo) returnfoo.bar(); 1221.1322.publicvoidtestFoo() 1423.1524.classAimplementsFoo 1625.publicintbar() return2; 1726. 1827.1928. System.out.println( fubar(newA();2029. 2130.2231.publicstaticvoidmain( String argv) 2332.newBeta().testFoo();2433. 2534. o A.编译错误o B.运行代码输出:2o C.如果删除16,17,18行,运行代码应然输出:2o D.如果删除24,25,26行,运行代码输出:1正确答案:A解析: 4.(单选题)分析如下语句,说法错误的是()。o A.break可用于跳出循环,当多层嵌套时,只用于跳出一层循环o B.break即可以出现在循环语句中也可以出现在switch语句中o C.continue可以用于跳出循环o D.continue不能出现在switch语句中正确答案:C解析: 5.(单选题)在Java语言中,下列说法正确的是:()。o A.Java访问修饰符按照访问范围由低到高的排列顺序是public,default,protected,privateo B.private可以用于外部类的声明o C.一个Java源文件中声明为public的外部类只能有一个o D.protected声明的方法不可以被子类重写正确答案:C解析: 6.(单选题)下列代码的输出结果是:01classCup 0203classPoisonCupextendsCup 04publicvoidtakeCup(Cup c) 05if(cinstanceofPoisonCup) 06System.out.println(Inconceivable!);07elseif(cinstanceofCup) 08System.out.println(Dizzying intellect!);09else10System.exit(0);11121314publicclassTestCup 15publicstaticvoidmain(String args) 16Cup cup =newPoisonCup();17PoisonCup poison=newPoisonCup();18poison.takeCup(cup);1920o A.Inconceivable!o B.Dizzying intellect!o C.代码正常运行,但是无输出o D.抛出运行时异常正确答案:A解析: 7.(单选题)请看下列代码编译和运行的结果是:01packagepackagea;02publicclassMessage 03String getText() 04returntext;050607packagepackageb;08publicclassXMLMessageextendspackagea.Message09String getText() 10return1112text13;1415publicstaticvoidmain(String args) 16System.out.println(newXMLMessage().getText();1718o A.texto B.texto C.抛出运行时异常o D.代码public class XMLMessage extends packagea.Message行,编译错误正确答案:B解析: 8.(单选题)下列属于不合法Java标识符的是()。o A._avajo B.5saveo C.Avajo D.$80正确答案:B解析: 9.(单选题)编译和运行以下代码的结果为()。1publicclassMyMain2publicstaticvoidmain(String argv)3System.out.println(Hello cruel world);45o A.编译错误o B.运行输出 Hello cruel worldo C.编译无错,但运行时指示没有定义构造方法o D.编译无错,但运行时指示没有正确定义main方法正确答案:D解析: 10.(单选题)下列代码编译和运行的结果是:01publicclassWow 02publicstaticvoidgo(shortn) 03System.out.println(short);0405publicstaticvoidgo(Short n) 06System.out.println(SHORT);0708publicstaticvoidgo(Long n) 09System.out.println( LONG);1011publicstaticvoidmain(String args) 12Short y =6;13intz =7;14go(y);15go(z);1617o A.short LONGo B.SHORT LONGo C.编译失败o D.抛出运行时异常正确答案:C解析: 11.(单选题)在Java语言中,字符串“Java程序员”在内存中所占用的字节数是:()。o A.10o B.7o C.13o D.14正确答
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号