题目内容

执行下列代码后,输出结果是( )StringBuilder buf=new StringBuilder(20);System.out.println(buf.length()+","+buf.capacity());

A. 0,20
B. 0,null
C. 20,20
D. 0,0

查看答案
更多问题

执行下面代码后,将创建()个对象。String s1="hello";String s2="hello";

A. 0
B. 1
C. 2
D. 3

执行下面代码后,将创建()个对象。String s1="hello";String s2=new String(s1);

A. 0
B. 1
C. 2
D. 3

执行下面代码后,输出的结果为()public class Test {public static void main(String[] args) {String s1="hello";String s2=new String(s1);if(s1==s2)System.out.println("s1==s2");elseSystem.out.println("s1!=s2");if(s1.equals(s2))System.out.println("s1 equals s2 ");elseSystem.out.println("s1 not equals s2");}}

A. s1==s2s1 equals s2
B. s1!=s2s1 equals s2
C. s1==s2s1 not equals s2
D. s1!=s2s1 not equals s2

有语句“String s="hello world";”,以下操作不合法的是()

A. s>>>=1;
B. int i=s.length();
C. String ts=s.trim();
D. String t=s+"!";

答案查题题库