第十章测试
1.

String str1=new String("java");
String str2=new String("java");
StringBuffer str3=new StringBuffer("java");
对于上述定义的变量,以下表达式的值为true的是哪个?(   


A:str1==str2 B:str1.equals(str2) C:以上都不对 D:str1==str3
答案:B
2.

阅读下面一段代码

Integer in1 = new Integer(10);
Integer in2 = new Integer(10);
Integer in3 = 10;
Integer in4 = 10;
System.out.print(in1 == in2);
System.out.print(in1 == in3);
System.out.print(in3 == in4);
下列选项中,程序的运行结果是(   



A:false false false B:true true true C:false false true D:false true false 3.假如indexOf()方法未能找到所指定的子字符串,那么其返回值为?(   
A:以上答案都不对 B:false C:-1 D:0 4.

阅读下列代码

public class Example {
    public static void main(String[] args) {
        int[] srcArray = { 11, 12, 13, 14 };
        int[] destArray = { 21, 22, 23, 24 };
        System.arraycopy(srcArray, 1, destArray, 2, 2);
        for (int i = 0; i < destArray.length; i++) {
            System.out.print(destArray[i] + " ");
        }
    }
}
下列选项中,程序的运行结果是?(    )



A:发生数组角标越界异常 B:21 11 12 24 C:21 22 12 13 D:21 22 11 12 5.

要产生[20999]之间的随机整数可以使用以下哪个表达式?(  


A:20+(int)(Math.random()*980) B:(int)Math.random()*999 C:20+(int)Math.random()*980 D:(int)(20+Math.random()*97) 6.

下列关于包装类的描述中,错误的是?(    )


A:可以通过继承包装类完成自定义包装类的设计 B:包装类它可以完成在基本类型与String类型之间的转换
C:包装类对应着基本数据类型
D:包装类的作用之一就是将基本类型包装成引用类型
7.

下列选项中,可以正确实现String初始化的是(    


A:String str = abc; B:String str = 0; C:String str = "abc"; D:String str = 'abc'; 8.

已知 String 对象 s="abcdefg",则 s.substring(2, 5)的返回值为?(   


A:"cde" B:"def" C:"bcde" D:"cdef" 9.

下列选项中,哪个是StringBuffer类中append()方法的返回值类型?(    


A:String B:StringBuilder C:void D:StringBuffer 10.

System类中提供的属性和方法都是静态的。(     



A:错 B:对 11.

System类中的currentTimeMillis()方法返回一个long类型的值。(     



A:对 B:错 12.

包装类可以将基本数据类型的值包装为引用数据类型的对象。   (      



A:错 B:对 13.

使用字符串常量可以直接初始化一个String对象。(     



A:错 B:对 14.

StringBuffer类似一个字符容器,当在其中添加或删除字符时,并不会产生新的StringBuffer对象。(    



A:错 B:对 15.

字符串一旦初始化就不可以被改变。(    



A:错 B:对

温馨提示支付 ¥4.99 元后可查看付费内容,请先翻页预览!
点赞(193) dxwkbang
返回
顶部