String s = new String("xyz");创建了几个String Object? 二者之间有什么区别?
String s = new String("xyz");创建了几个String Object?
二者之间有什么区别?
String s = new String("xyz");创建了几个String Object?
二者之间有什么区别?
第1题
A.String str = s.append(“aaa”);
B.String str = s.concat(s);
C.String str = s.substring(3);
D.以上语句都不会
第4题
假设有以下代码: String s="hello"; String t="hello"; char c[ ]={'h','e','l','l','o'}; 下列选项中,返回false的语句是______。
A.s.equals(t);
B.t.equals(c);
C.s==t;
D.t.equals(new String("hello"));
第5题
关于以下代码段的说法正确的是()。 (1) String s="abcde"; (2) String Buffer s1=new String Buffer("abcde"); (3) if(s.equals(s1)) (4) s1=null: (5) if(s1.equals(s)) (6) s=null;
A.第(1)行编译错误,String的构造器必须明确调用
B.第(3)行编译错误,因为s与s1有不同的类型
C.编译成功,但执行时在第(5)行有异常抛出
D.编译成功,执行过程中也没有异常抛出
第6题
A. 输出结果为:0
B. 无输出
C. 编译错误
D. 输出null
第7题
import java.io.*;
public class A{
public static void main(String[] x){
String s="1234567890abcdefghijklmnopq";
byte[] b=s.getBytes();
try{
File f=new File("B.txt");
FileOutputStream ut=new FileOutputStream(f);
out.write(b,10,10);
out.write(b,0,5);
}catch (IOException e){
System.out.println(e.getMessage());
}
}
}
A.抛出一个可以被捕获的IOException
B.程序编译正常,并在当前目录下生成文件B.txt,文件内容为abcdefghij12345
C.编译正常,但运行时出现错误
D.程序编译正常,但屏幕没有任何输出
第9题
A.'foo' == new function(){ return String('foo'); }
B.'foo' == new function(){ return new String('foo'); }
C.[] == 0
D.![]
E.!0