1609第一次月考详细解析 联系客服

发布时间 : 星期日 文章1609第一次月考详细解析更新完毕开始阅读d174d613eef9aef8941ea76e58fafab069dc4409

B.break即可以出现在循环语句中也可以出现在switch语句中 C.continue可以用于跳出循环 D.continue不能出现在switch语句中 正确答案:C

break”语句用来结束循环,即不再执行后边的所有循环。

“continue”语句用来结束当前循环,并进入下一次循环,即仅仅这一次循环结束了,不是所有循环结束了,后边的循环依旧进行。

34.

(单选)请看下列代码编译和运行的结果是: package packagea; public class Message {

String getText() { return \package packageb;

public class XMLMessage extends packagea.Message{ String getText() {

return \

public static void main(String[] args) {

System.out.println(new XMLMessage().getText()); } }直接new对象了 A.text

B.text C.抛出运行时异常

D.代码public class XMLMessage extends packagea.Message{行,编译错误 正确答案:B

这题中XMLMessage继承Message是一个幌子,在println方法中我们new出来得是XMLMessage对象,直接调用XMLMessage的getText方法

35.

(单选)程序执行的结果是()。 public class Test { String name=\public Test(String name){

this.name=name; }//没有this

public static void main(String [] args){ Test t = new Test(\

System.out.println(t.name); } }//直接访问成员变量 A.null B.Tom C.Jack D.\正确答案:B 36.

(单选)请看下列代码的输出结果是: public class Bootchy { int bootch;

String snootch;

public Bootchy() { 构造方法的重载 this(\ 第一先进来这里 System.out.print(\最后输出 }

public Bootchy(String snootch) { this(420, \第二进这里

System.out.print(\其次输出 }

public Bootchy(int bootch, String snootch) { this.bootch = bootch; 第三进这里 this.snootch = snootch;

System.out.print(\首先输出 }

public static void main(String[] args) { Bootchy b = new Bootchy();

System.out.print(b.snootch + \ A.first second third snootchy 420 B.third second first snootchy 420 C.third first second snootchy 420

D.first second first third snootchy 420 正确答案:B

37.(单选)下列代码的输出结果是:()。 public class StaticFoo { int num;

static int x;

public static void main(String[] args) { StaticFoo foo1 = new StaticFoo (); foo1.num++; foo1.x++;

StaticFoo foo2 = new StaticFoo (); foo2.num++; foo2.x++;

StaticFoo foo3 = new StaticFoo (); foo3.num++; foo3.x++; StaticFoo.x++;