R2-1
在java.lang.Integer类中,哪个方法用于获得一个整数的二进制形式的字符串?( )
(2分)
A.
toHexString(int i)
B.
toString(int i)
C.
toBinaryString(int i)
D.
toOctalString(int i)
R2-2
下面选项中能把字符串转换成float类型的是?( )
(2分)
A.
float value = Float.parseFloat(str);
B.
float value = new Float(str);
C.
float value = (new Float()).parseFloat(str)
D.
float value = Float.floatValue(str);
R2-3
关于基本类型的数据与其封装类对象之间的转换,下面说法错误的是( )。
(2分)
A.
Integer类型的对象可以通过拆箱,可以自动转化为int基本类型的数值。
B.
int类型的数据通过装箱操作,可以自动转换成Integer类型的对象。
C.
int类型的数值通过装箱操作,可以自动封装为Long 类型对象
D.
long类型的数据通过装箱操作,可以自动封装为Long类型对象
R2-4
Which of the following statement is true?
(2分)
A.
The equals() method of any class determines if reference values refer to the same object.
B.
The equals() method of any class returns true only when the contents of two objects match.
C.
The == operator determines if the contents and type of two separate objects match.
D.
The class File overrides equals() to return true if the contents and type of two separate objects match.
R2-5
下面哪条语句可以将字符串s转换为double类型的值d?
(2分)
A.
d = Double.parseDouble(s);
B.
以上所有
C.
d = Double.valueOf(s).doubleValue();
D.
d = (new Double(s)).doubleValue();
R2-6
Given code below:
class Value {
int i;
}
public class Test {
public static void main(String[] argv) {
Integer v1 = 39;
Integer v2 = 39;
System.out.println(v1.equals(v2));
}
}
Which of the following statement is true?
(2分)
A.
It does not compile because of line 6 and 7, that the type are not match for assignment operator.
B.
It compiles and print out “true”.
C.
It compiles and print out “false”.
D.
It compiles but exception raises for line 6 at run time: type mismatch.