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.
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++;
System.out.print(foo3.num+\System.out.println(foo3.x); } } A.3,3 B.1,3 C.3,4 D.1,4 正确答案:D
静态变量,也就是在变量前加了static 的变量;也叫类变量,只有一份,存在方法区 实例变量也叫对象变量,即没加static 的变量;
区别在于:静态变量和实例变量的区别在于:静态变量是所有对象共有,其中一个对象将它值改变,其他对象得到的就是改变后的结果;而实例变量则属对象私有,某一个对象将其值改变,不影响其他对象
38.
(单选)请看下列程序的输出结果是: public class Item { private String desc;
public String getDescription() { return desc; }
public void setDescription(String d) { desc = d; }
public static void modifyDesc(Item item, String desc) { item = new Item();
item.setDescription(desc); }
public static void main(String[] args) {
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库1609第一次月考详细解析(5)在线全文阅读。
相关推荐: