达内java2015.11第一次月考(附答案).doc

o A.

a=100, b=300

o

B.

a=100, b=200

o

C.

a=200, b=100

o

D.

a=300, b=200

正确答案:B

? 23.

(单选)下列代码的输出结果是: public class Yikes { public static void go(Long n) { System.out.println(\n) { System.out.println(\{ System.out.println(\{ short y = 6; long z = 7; go(y); go(z); } }

o

A.

Long Long

o

B.

Short Long

o

C.

int Long

o

D.

int int

正确答案:C

? 24.

(单选)分析如下语句,说法错误的是()。

o

A.

break可用于跳出循环,当多层嵌套时,只用于跳出一层循环

o B.

break即可以出现在循环语句中也可以出现在switch语句中

o

C.

continue可以用于跳出循环

o

D.

continue不能出现在switch语句中

正确答案:C

? 25.

(单选)A类中有一个方法:protected int print(String str){},B类继承A类, 以下方法能在B类中重写A类中print()方法的是: ()。

o

A.

public int print(String str){}

o

B.

private int print(String str){}

o

C.

private void print(String str){}

o

D.

public void print(String str){}

正确答案:A

? 26.

(单选)下列代码的运行结果是: String test = \String regex = \(String s : result) System.out.print(s + \

o

A.

Test A Test B Test C

o

B.

Test A. Test B. Test C.

o

C.

Test . Test . Test .

o

D.

A. B. C.

正确答案:A

? 27.

(单选)请看下列代码 public class Member{ private Long userId; private String nickName; //以下是getter和sett方法 ?? } Main方法中的代码: Member m1=new Member(); m1.setUserId(new Long(100001));

m1.setNickName(\Long(100001)); m2.setNickName(\System.out.println(m1.equals(m2)); 控制台的输出结果是:

o

A.

true false

o

B.

false true

o

C.

false false

o

D.

true ture

正确答案:C

? 28.

(单选)实现Point类的equals方法,具体逻辑为:“成员变量x和y分别相等的Point对象被视为相等”。 public class Point { private int x; private int y; ... public boolean equals(Object obj) { 《填入代码》 } } 《插入代码》处应填入的代码正确的是:

o

A.

if(obj.x == this.x || obj.y == this.y){ return true; } return false;

o

B.

if(obj.x == this.x && obj.y == this.y){ return true; } return false;

o

C.

if(!(obj instanceof Point)) return false; if(((Point)obj).x == ((Point)obj).y && this.x == this.y){ return true; } return false;

o

D.

if(!(obj instanceof Point)) return false; if(((Point)obj).x == this.x && ((Point)obj).y == this.y){ return true; } return false;

正确答案:D

? 29.

(单选)运行下列代码,输出为false的是:()。

o

A.

String st1 = \

o

B.

String st2 = \

o

C.

Integer i = 100; System.out.println(100 == i);

o

D.

ArrayList list = new ArrayList();

System.out.println(list.contains(null));

正确答案:A

? 30.

(单选)请看下列代码,出现错误的行是:() public interface Cookie{ Cookie cookie=new Cart (\小面包\盼盼\Cookie{ private String name; private String production; public Cart(String name,String production){ this.name=name;

this.production=production; } public void smell(){ cookie =new Cart(\蛋黄派\达利园\

o

A.

第2行

o B.

第4行

o

C.

第11行

o

D.

第12行

正确答案:D

? 31.

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

System.out.print(\\} public Bootchy(String snootch) { this(420, \String snootch) { this.bootch = bootch; this.snootch = snootch; System.out.print(\{ Bootchy b = new Bootchy(); System.out.print(b.snootch + \b.bootch); } }

o

A.

first second third snootchy 420

o

B.

third second first snootchy 420

o

C.

third first second snootchy 420

o

D.

first second first third snootchy 420

正确答案:B

? 32.

(单选)下列语句创建对象的总个数是:()。 String s=”a”+”b”+”c”+”d”+”e”;

o

A.

联系客服:779662525#qq.com(#替换为@) 苏ICP备20003344号-4