网友您好, 请在下方输入框内输入要搜索的题目:
题目内容
(请给出正确答案)
1.importjava.util.*;
2.classSubGen{
3.publicstaticvoidmain(String[]args){
4.//insertcodehere
5.}
6.}
classAlpha{}
classBetaextendsAlpha{}
classGammaextendsBeta{}
和四段代码片段:
s1.ArrayList〈?extendsAlpha〉list1=newArrayList〈Gamma〉();
s2.ArrayList〈Alpha〉list2=newArrayList〈?extendsAlpha〉();
s3.ArrayList〈?extendsAlpha〉list3=newArrayList〈?extendsBeta〉();
s4.ArrayList〈?extendsBeta〉list4=newArrayList〈Gamma〉();ArrayList〈?extendsAlpha〉list5=list4;
哪些片段分别插入到第4行,可允许代码编译?()
参考答案
更多 “ 1.importjava.util.*;2.classSubGen{3.publicstaticvoidmain(String[]args){4.//insertcodehere5.}6.}classAlpha{}classBetaextendsAlpha{}classGammaextendsBeta{}和四段代码片段:s1.ArrayList〈?extendsAlpha〉list1=newArrayList〈Gamma〉();s2.ArrayList〈Alpha〉list2=newArrayList〈?extendsAlpha〉();s3.ArrayList〈?extendsAlpha〉list3=newArrayList〈?extendsBeta〉();s4.ArrayList〈?extendsBeta〉list4=newArrayList〈Gamma〉();ArrayList〈?extendsAlpha〉list5=list4;哪些片段分别插入到第4行,可允许代码编译?() ” 相关考题
考题
importjava.util.*;2.3.ClassFindStuff{4.publicstaticvoidmain(String[]args){5.//insertcodehere6.c.put(x,123);7.}8.}分别插入到第5行,哪三行允许代码编译?()
A.Mapc=newSortedMap();B.HashMapc=newHashMap();C.HashMapc=newHashtable();D.SortedMapc=newTreeMap();
考题
importjava.util.*;classBanana3{publicstaticvoidmain(String[]args){intx=2;Banana3b=newBanana3();b.go(x);}static{x+=x;}voidgo(intx){++x;System.out.println(x);}}结果为:()
A.2B.3C.5D.编译失败
考题
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.*;publicclassPQ{publicstaticvoidmain(String[]args){PriorityQueuepq=newPriorityQueue();pq.add(”carrot”);pq.add(”apple”);pq.add(”banana”);System.out.println(pq.poll()+”:”+pq.peek());}}Whatistheresult?()A.apple:appleB.carrot:appleC.apple:bananaD.banana:appleE.carrot:carrotF.carrot:banana
考题
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
考题
7、以下程序的运行结果是()。 import java.util.*; public class Test{ public static void main(String[] args){ List<Integer> list= Arrays.asList(1,2,3,4); int sum=0; for(int s:list) sum+=s; System.out.println(sum); } }A.1234B.10C.1,2,3,4D.0
热门标签
最新试卷