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

(多选)题目代码的功能为:输出每个字符在一个字符串中出现的次数(不区分大小写)。 String str = \int max_length = 0; while (str.length() > 0) { 《插入代码》 }

o

A.

int length = str.length(); char first=str.charAt(0); String strNew = str.replaceAll(String.valueOf(first), \

(length>strNew.length()) { max_length = length - strNew.length(); System.out.println(first+\

o

B.

int length = str.length(); char first=str.charAt(0); String strNew = str.replaceAll(String.valueOf(first), \(length>strNew.length()) { max_length = length - strNew.length(); str = strNew; System.out.println(first+\

o

C.

int length = str.length(); String first = str.substring(0, 1); String strNew = str.replaceAll(first, \{ max_length = length - strNew.length(); str = strNew; System.out.println(first+\

o

D.

int length = str.length(); String first = str.substring(0, 1); String strNew = str.replaceAll(first, \{ max_length = length - strNew.length(); System.out.println(first+\

正确答案:BC

? 43.

(多选)在Java语言中,下列说法正确的是:()。

o

A.

StringBuffer和StringBuilder的区别在于:StringBuffer是线程安全的而StringBuilder不是。

o

B.

String是不可变对象,而StringBuffer中封装的字符串数据是可以动态改变的。

o

C.

判断两个StringBuilder对象的字符序列是否相同,可以调用其equlas方法进行比较。

o

D.

String的重写了equals方法,重写的逻辑是:字符序列相同的String对象equals方法返回true。

正确答案:ABD

? 44.

(多选)下面的方法属于StringBuffer的是:()。

o

A.

size

o

B.

insert

o

C.

delete

o

D.

length

正确答案:BCD

? 45.

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

o

A.

Object o = Old.get(new LinkedList());

o

B.

Object o = Old.get(new LinkedList<?>());

o

C.

String s = Old.get(new LinkedList<String>());

o

D.

String s = (String)Old.get(new LinkedList<String>());

正确答案:ABD

? 46.

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

o

A.

public int method(String str,int age){}

o

B.

public void method(int year,String s){}

o

C.

public int method(int year,String s){}

o

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 { <插入代码> } 下列选项中的代码,放置在<插入代码>处无编译错误的是:

o

A.

public void foo() { }

o

B.

public Object foo() { return this; }

o

C.

public Two foo() { return this; }

o

D.

public One foo() { return this; }

正确答案:ACD

? 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); } } 下列选项中,空白处可以填入的代码是:()。

o

A.

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

o

B.

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

o

C.

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

o

D.

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

正确答案:AC

? 49.

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

o

A.

int a = 8888888888;

o

B.

char b = 1000+300;

o

C.

byte c = 100+30;

o

D.

int d = 'a'+'b'+'c';

正确答案:AC

? 50.

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

o

A.

\

o

B.

\

o

C.

\

o

D.

\

正确答案:BCD

关于我们 | 服务支持 | 咨询与反馈 | 最新动态 | 代理合作 | 名师堂

达内时代科技集团有限公司 2013-2014

中关村中心企业合作:62117598 UID中心企业合作:82168421、82168831

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