s.append(“aaa”)
s.concat(s)
s.substring(3)
以上语句都不会
第1题:
假设有以下代码: 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"));
第2题:
A.s.equals(t);
B.t.equals(c);
C.s==t;
D.t.equals(newString("hello"));
E.t==c;
第3题:
A.行4与行6都将执行
B.行4执行,行6不执行
C.行6执行,行4不执行
D.行 4、行6都不执行
第4题:
下列代码的执行结果是()。publicclasstest5{publicstaticvoidmain(Stringargs[]){Strings1=newString("hello");Strings2=newString("hello");System.out.prim(s1==s2);System.out.print(",");System.out.println(s1.equals(s2));}
A.true,false
B.true,true
C.false,true
D.false,false
第5题:
A.Theprogramrunsandprints“Hello”
B.Anerrorcausescompilationtofail.
C.Theprogramrunsandprints“Helloworld!”
D.Theprogramrunsbutabortswithanexception.
第6题:
importjava.util.*;publicclassWrappedString{privateStrings;publicWrappedString(Strings){this.s=s;}publicstaticvoidmain(String[]args){HashSeths=newHashSet();WrappedStringws1=newWrappedString(”aardvark”);WrappedStringws2=newWrappedString(”aardvark”);Strings1=newString(”aardvark”);Strings2=newString(”aardvark”);hs.add(ws1);hs.add(ws2);hs.add(s1);hs.add(s2);System.out.println(hs.size());}}Whatistheresult?()
A.0
B.1
C.2
D.3
E.4
F.Compilationfails.
G.Anexceptionisthrownatruntime.
第7题:
A.Theprogramrunsandprints“Hello”
B.Anerrorcausescompilationtofail.
C.Theprogramrunsandprints“Helloworld!”
D.Theprogramrunsbutabortswithanexception.
第8题:
A.s.append(“x”);
B.s.concat(“y”);
C.s.substring(3);
D.以上语句都不会
第9题:
以下选项中正确的语句组是( )。
A)char s[];s="HELLO!";
B)char*s;s={"HELLO!"};
C)char s[10];s="HELLO!";
D)char *s;s="HELLO!";
第10题:
下列语句输出结果为( )。 public class test { public static void main (String args[]) { Strings1=newString("HOW"); Strings2=newString("How"); System.out.println(!(s1.equals(s2))): } }
A.假
B.真
C.0
D.1