达内jsd1510第一次月考题,java第一阶段面向对象语法基础考试试题 下载本文

(多选)请看下列代码: public class Old { public static Object get(List list) { return list.get(0); } } 以下选项调用get方法,能编译通过的是:

A.Object o = Old.get(new LinkedList()); B.Object o = Old.get(new LinkedList()); C.String s = Old.get(new LinkedList()); D.String s = (String)Old.get(new LinkedList()); 正确答案:AD 46.

(多选)查看如下代码: public class Foo { public void method(String str,int age){} } 下列选项中,和 Foo 类中 method 方法重载的方法是()。

A.public int method(String str,int age){} B.public void method(int year,String s){} C.public int method(int year,String s){} D.public int method(String str){} 正确答案:BCD 47.

(多选)请看下列代码: class One { public One foo() { return this; } } class Two extends One { public One foo() { return this; } } class Three extends Two { <插入代码> } 下列选项中的代码,放置在<插入代码>处无编译错误的是:

A.public void foo() { }

B.public Object foo() { return this; } C.public Two foo() { return this; } D.public One foo() { return this; } 正确答案:CD 48.

(多选)所谓“水仙花”数是一个整数等于各位数字立方的和,例如:153 = 1*1*1+5*5*5+3*3*3,下面的程序用于输出2~1000内的水仙花数: for (int n = 2; n <= 1000; n++) { 空白处 if (s == n) { System.out.println(n); } } 下列选项中,空白处可以填入的代码是:()。

A.int s = 0, n1 = n; while (n1 > 0) { int t = n1 % 10; s += t * t * t; n1 /= 10; }

B.int s = 0, n1 = n; while (n1 > 0) { int t = n1 / 10; s+= t * t * t; n1 %= 10; }

C.int s = 0; for(int n1 = n; n1>0; n1 /= 10) { int t = n1; s += t * t * t; }

D.int s = 0; for(int n1 = n; n1>0; n1 %= 10) { int t = n1 / 10; s += t * t * t; }

正确答案:AC 49.

(多选)下列赋值语句中,会有编译错误的是()。

A.int a = 8888888888; B.char b = 1000+300; C.byte c = 100+30; D.int d = 'a'+'b'+'c'; 正确答案:AC 50.

(多选)下列逻辑表达式,值为false的是()。 A.\ B.\

C.\ D.\正确答案:BCD