分数 2
作者 翁恺
单位 浙江大学
What is the value of s2
after this code executes?
1. String s1 = "Happy#day"; 2. String s2 = s1.substring(1,5);
A.
"Happ"
B.
"Happy"
C.
"appy"
D.
"appy#"
2-2
分数 2
作者 翁恺
单位 浙江大学
The result of code below is:
1. public class Test { 2. public static void main(String args[]){ 3. String str="ABCDE"; 4. str.substring(3); 5. str.concat("XYZ"); 6. System.out.print(str); 7. }}
A.
DE
B.
DEXYZ
C.
ABCDE
D.
CDEXYZ
2-3
分数 2
作者 翁恺
单位 浙江大学
Given code below:
1. String s1 = "Hello"; 2. String s2 = "Hell"+"o"; 3. String s3 = "Hell"; 4. s3 = s3+"o";
Which one below is correct?
A.
s1 == s2 is true, s1 == s3 is true
B.
s1 == s2 is true, s1 == s3 is false
C.
s1 == s2 is false, s1 == s3 is false
D.
s1 == s2 is false, s1 == s3 is true
2-4
分数 2
作者 翁恺
单位 浙江大学
For String s;
, which statement below is correct?
A.
s is a variable not initialized, and is to be a pointer to an object of String
.
B.
At this line, s is a variable holding an object of String
.
C.
It will hold an object of String
, given s
a member variable,.
D.
It will hold an object of String
, given s
a local variable.
2-5
分数 2
作者 翁恺
单位 浙江大学
For code below, the result would be?
1. String s = " Welcome to Zhejiang University "; 2. s.trim(); 3. System.out.println(s.startsWith("Welcome"));
A.
true
B.
false
C.
Compile error
D.
Run-time exception
2-6
分数 2
作者 翁恺
单位 浙江大学
For code below, the result would be?
1. String s = "Welcome to Zhejiang University"; 2. String[] a = s.split(" "); 3. System.out.println(a.length);
A.
4
B.
3
C.
Compile error
D.
Run-time exception
2-7
分数 2
作者 徐硕博
单位 浙江大学
What is the value of s2 after this code executes?
String s1 = "Happy day";
String s2 = s1.substring(1,5);
,分值为2分。
A.
"Happ"
B.
"Happy"
C.
"appy"
D.
"appy "
2-8
分数 2
作者 翁恺
单位 浙江大学
What will be output by the following line?
System.out.println(Math.floor(-2.1));
A.
-2
B.
2.0
C.
-3
D.
-3.0
正确答案:D