1 / 11
文档名称:

【精品】java笔试题06.doc

格式:doc   大小:124KB   页数:11
下载后只包含 1 个 DOC 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

【精品】java笔试题06.doc

上传人:小雄 2021/10/10 文件大小:124 KB

下载得到文件列表

【精品】java笔试题06.doc

相关文档

文档介绍

文档介绍:Using the java. lang. String Class
Given the following,
public class StringRef (
public static void main(String [] args) {
String si = 〃abc〃;
String s2 = 〃def〃;
String s3 = s2;
s2 = 〃ghi〃;
System, out. println(sl + s2 + s3);
}
}
what is the result?
abcdefghi
abcdefdef
abcghidef
abcghighi
Compilation fails.
An exception is thrown at runtime.
Given the following,
String x 二 〃xyz〃;
x. toUpperCase ();
String y = x. replace ('Y', ' y');
y = y + 〃abc〃;
System, out. printIn(y);
what is the result?
abcXyZ
abcxyz
xyzabc
XyZabc
Compilation fails.
An exception is thrown at runtime.
Given the following,
String x = new String("xyz");生成两个字符串
String y = 〃abc〃;
x = x + y;
how many String objects have been created?
2
3
.
5
Given the following,
String a = "newspaper”;
a = a. substring(5, 7) ;substring截字符串的,截取到end - 1 的位置
char b二a. charAt(l) ; char At他是截取单个字符,从0开始
a = a + b;
System, out. printIn(a);
what is the result?
apa
apea
apep
papp
papa
Given the following,
String d ="bookkeeper”;
d. substring (1, 7);
d 二 〃w〃 + d;
d. append(/zwoo/z) ;String类没有append。方法
System, out. println(d);
what is the result?
wookkeewoo
wbookkeeper
wbookkeewoo
wbookkeeperwoo
Compilation fails.
An exception is thrown at runtime.
Using the java. lang. Math Class
Given the following,
public class Example {
public static void main(String [] args) {
double values []={-2. 3, -1. 0, 0. 25, 4};
int ent 二 0;
for (int x=0; x < values, length; x++) {
if (Math, round(values[x] + . 5)二二 Math, ceil(values[x]))
++cnt;
}
}
System, out. print In (^same results 〃 + ent + 〃 time(s)/z);
}
}
what is the result?
Round:四舍五入
Math, round(11. 6) = 12 Math, round(-11. 6) = -12
Ceil:向上取整
Math, ceil(x) >=
Floor:向下取整
Math, floor(x) <= x
same results 0 time(s)
same results 2 time(s)
same results 4 time(s)
Compilation fails.
An exception is thrown at runtime.
Which of the following are valid calls to Math, max? (Choose all that apply.) (Yeah, yea