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.0B.1C.2D.3E.4F.Compilationfails.G.Anexceptionisthrownatruntime.

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.


相关考题:

分析两个字符串,分别输出每个字符串的单词并统计出单词个数。阅读程序,填写空行。注意:不改动程序结构,不得增行或删行。import java.util.*;public class ex2{public static void main(String args[]){String s1="I am Chinese,she is my girlfriend";String s2="Oh,really,fine";StringTokenizer fenxi_1=new StringTokenizer(s1,",");StringTokenizer fenxi_2=new StringTokenizer(s2,",");int n1=fenxi_1.countTokens();int n2=fenxi_2.countTokens();while(fenxi_1.hasMoreTokens()){String s=fenxi_1.nextToken();System.out.println(s);}System.out.println("s1单词:"+n1+"个");while(fenxi_1.hasMoreTokens()){String s=______;System.out.println(s);}System.out.println("s2单词:"+n2+"个");}}

importjava.util.*;classScanStuff{publicstaticvoidmain(String[]args){Strings=x,yy,123;Scannersc=newScanner(s);while(sc.hasNext())System.out.print(sc.next()+);}}结果是什么?() A.xyyB.x,yyC.xyy123D.x,yy,123

现有:importjava.util.*;classAddStuff2{publicstaticvoidmain(String[]args){TreeSett=newTreeSet();if(t.add(one))if(t.add(two))if(t.add(three))add(four);for(Strings:t)System.out.print(s);}}结果为:()A.oneB.onethreetwoC.onetwothreeD.onetwothreefourE.fouronethreetwoF.编译失败

现有:importjava.util.*;classScanStuff{publicstaticvoidmain(String[]args){StringS=x,yy,123;Scannersc=newScanner(s);while(sc.hasNext())System.out.print(sc.next()+);}}结果是什么?() A.xyyB.x,yy,123C.xyy123D.x,yyE.编译失败F.运行的时候有异常抛出

importjava.util.*;publicclassLetterASort{publicstaticvoidmain(String[]args){ArrayListstrings=newArrayList();strings.add(?aAaA”);strings.add(”AaA”);strings.add(?aAa”);strings.add(”AAaa”);Collections.sort(strings);for(Strings:strings){System.out.print(s+);}}}Whatistheresult?()A.Compilationfails.B.aAaAaAaAAaaAaAC.AAaaAaAaAaaAaAD.AaAAAaaaAaAaAaE.aAaAaAaAaAAAaaF.Anexceptionisthrownatruntime.

importjava.util.*;2.publicclassTest{3.publicstaticvoidmain(String[]args){4.Liststrings=newArrayList();5.//insertcodehere6.}7.}Whichfour,insertedatline5,willallowcompilationtosucceed?() A.Strings=strings.get(0);B.Iteratori1=strings.iterator();C.String[]array1=strings.toArray();D.Iteratori2=strings.iterator();E.String[]array2=strings.toArray(newString[1]);F.Iteratori3=strings.iterator();

public class Something {void doSomething () {private String s = "";int l = s.length();}}有错吗?

8、下列程序执行的结果是___________。 import java.util.*; public class Example{ public static void main(String[] args){ String s="x,yy,123"; Scanner sc=new Scanner(s); while(sc.hasNext()){ System.out.print(sc.next()+" "); } } }A.x yyB.x,yy,123C.x yy 123D.x,yy

危害程度的分级范围,下面选项哪些是正确的A.轻度危害(Ⅳ级):THI<35B.中度危害(Ⅲ级):THI≥35~<50C.高度危害(Ⅱ级):THI≥50~<65D.极度危害(工级):THI≥65