7.
What is the output of the following code?
public class Test {
public static void main(String[] args) {
java.math.BigInteger x = new java.math.BigInteger("3");
java.math.BigInteger y = new java.math.BigInteger("7");
x.add(y);
System.out.println(x);
}
}
单选题 (2 分) 2 分
4
10
3
11
9.
Which of the following statements convert a double value d into a string s?
回答错误
单选题 (2 分) 0 分
s = (Double.valueOf(s)).toString();
s = new Double(d).stringOf();
s = (new Double(d)).toString();
s = String.stringOf(d);
10.
__________ returns a string.
多选题 (2 分) 2 分
String.valueOf(false)
String.valueOf(new char[]{'a', 'b', 'c'})
String.valueOf(12.53)
String.valueOf(123)
11.
What is the output of Integer.parseInt("10", 2)?
单选题 (2 分) 2 分
1;
2;
Invalid statement;
10;
13.
Suppose s1 and s2 are two strings. Which of the following statements or expressions are incorrect?
多选题 (2 分) 2 分
int i = s1.length
s1.charAt(0) = '5'
String s3 = s1 + s2
String s = new String("new string");
s1 >= s2
17.
In JDK 1.5, you may directly assign a primitive data type value to a wrapper object. This is called ______________.
单选题 (2 分) 2 分
auto boxing
auto conversion
auto casting
auto unboxing
20.
Which of the following is the correct statement to return a string from an array a of characters?
单选题 (2 分) 2 分
String.toString(a)
toString(a)
convertToString(a)
new String(a)
22.
Which of the following statements will convert a string s into i of int type?
回答错误
多选题 (2 分) 0 分
i = (new Integer(s)).intValue();
i = (int)(Double.parseDouble(s));
i = Integer.valueOf(s);
i = Integer.parseInt(s);
i = Integer.valueOf(s).intValue();
28.
___________ is attached to the class of the composing class to denote the aggregation relationship with the composed object.
单选题 (2 分) 2 分
An empty diamond
An empty oval
A solid diamond
A solid oval
30.
Which of the following is an object?
多选题 (2 分) 2 分
new String("abc");
343
new Date()
"abc"
38.
What is displayed by the following code?
System.out.print("A,B;C".replaceAll(",;", "#") + " ");
System.out.println("A,B;C".replaceAll("[,;]", "#"));
单选题 (2 分) 2 分
A#B#C A#B#C
A B C A#B#C
A B C A B C
A,B;C A#B#C
41.
Which of the following statements are correct?
回答错误
多选题 (2 分) 0 分
new java.math.BigInteger(343);
new java.math.BigDecimal("343.445");
new java.math.BigDecimal(343.445);
new java.math.BigInteger("343");
42.
Assume s is "ABCABC", the method __________ returns an array of characters.
单选题 (2 分) 2 分
s.toCharArray()
s.toChars()
String.toChars()
String.toCharArray()
toChars(s)
45.
What is the printout of the following code?
String s1 = "Welcome to Java";
String s2 = "Welcome to Java";
System.out.println("s1 == s2 is " + s1 == s2);
单选题 (2 分) 2 分
s1 == s2 is true
true
false
s1 == s2 is false
46.
Which of the following statements will convert a string s into a double value d?
单选题 (2 分) 2 分
d = Double.parseDouble(s);
All of the above.
d = Double.valueOf(s).doubleValue();
d = (new Double(s)).doubleValue();
47.
Which of the following statements is correct?
多选题 (2 分) 2 分
Integer.parseInt("345", 8);
Integer.parseInt("12", 2);
Integer.parseInt(100);
Integer.parseInt("100");
Integer.parseInt(100, 16);
48.
What is displayed by the following code?
System.out.print("Hi, ABC, good".matches("ABC ") + " ");
System.out.println("Hi, ABC, good".matches(".*ABC.*"));
单选题 (2 分) 2 分
false false
true false
true true
false true
50.
Which of the following classes are immutable?
多选题 (2 分) 2 分
Integer
BigInteger
Double
String
BigDecimal