Java 面向对象程序设计 错题整理 chapter 10
作者:互联网
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 分
- A.
4
- B.
10
- C.
3
- D.
11
9.
Which of the following statements convert a double value d into a string s?
回答错误
单选题 (2 分) 0 分
- A.
s = (Double.valueOf(s)).toString();
- B.
s = new Double(d).stringOf();
- C.
s = (new Double(d)).toString();
- D.
s = String.stringOf(d);
10.
__________ returns a string.
多选题 (2 分) 2 分
- A.
String.valueOf(false)
- B.
String.valueOf(new char[]{'a', 'b', 'c'})
- C.
String.valueOf(12.53)
- D.
String.valueOf(123)
11.
What is the output of Integer.parseInt("10", 2)?
单选题 (2 分) 2 分
- A.
1;
- B.
2;
- C.
Invalid statement;
- D.
10;
13.
Suppose s1 and s2 are two strings. Which of the following statements or expressions are incorrect?
多选题 (2 分) 2 分
- A.
int i = s1.length
- B.
s1.charAt(0) = '5'
- C.
String s3 = s1 + s2
- D.
String s = new String("new string");
- E.
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 分
- A.
auto boxing
- B.
auto conversion
- C.
auto casting
- D.
auto unboxing
20.
Which of the following is the correct statement to return a string from an array a of characters?
单选题 (2 分) 2 分
- A.
String.toString(a)
- B.
toString(a)
- C.
convertToString(a)
- D.
new String(a)
22.
Which of the following statements will convert a string s into i of int type?
回答错误
多选题 (2 分) 0 分
- A.
i = (new Integer(s)).intValue();
- B.
i = (int)(Double.parseDouble(s));
- C.
i = Integer.valueOf(s);
- D.
i = Integer.parseInt(s);
- E.
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 分
- A.
An empty diamond
- B.
An empty oval
- C.
A solid diamond
- D.
A solid oval
30.
Which of the following is an object?
多选题 (2 分) 2 分
- A.
new String("abc");
- B.
343
- C.
new Date()
- D.
"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.
A#B#C A#B#C
- B.
A B C A#B#C
- C.
A B C A B C
- D.
A,B;C A#B#C
41.
Which of the following statements are correct?
回答错误
多选题 (2 分) 0 分
- A.
new java.math.BigInteger(343);
- B.
new java.math.BigDecimal("343.445");
- C.
new java.math.BigDecimal(343.445);
- D.
new java.math.BigInteger("343");
42.
Assume s is "ABCABC", the method __________ returns an array of characters.
单选题 (2 分) 2 分
- A.
s.toCharArray()
- B.
s.toChars()
- C.
String.toChars()
- D.
String.toCharArray()
- E.
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 分
- A.
s1 == s2 is true
- B.
true
- C.
false
- D.
s1 == s2 is false
46.
Which of the following statements will convert a string s into a double value d?
单选题 (2 分) 2 分
- A.
d = Double.parseDouble(s);
- B.
All of the above.
- C.
d = Double.valueOf(s).doubleValue();
- D.
d = (new Double(s)).doubleValue();
47.
Which of the following statements is correct?
多选题 (2 分) 2 分
- A.
Integer.parseInt("345", 8);
- B.
Integer.parseInt("12", 2);
- C.
Integer.parseInt(100);
- D.
Integer.parseInt("100");
- E.
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 分
- A.
false false
- B.
true false
- C.
true true
- D.
false true
50.
Which of the following classes are immutable?
多选题 (2 分) 2 分
- A.
Integer
- B.
BigInteger
- C.
Double
- D.
String
- E.
BigDecimal
标签:chapter,10,String,s1,Integer,错题,单选题,following,new 来源: https://blog.csdn.net/qq_51415695/article/details/121585131