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〈?

题目

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行,可允许代码编译?()


相似考题
更多“importjava.util.*;2.classSubGen{3. ”相关问题
  • 第1题:

    现有:importjava.util.*;classScanStuff{publicstaticvoidmain(String[]args){StringS="x,yy,123";Scannersc=newScanner(s);while(sc.hasNext())System.out.print(sc.next()+"");}}结果是什么?()

    A.xyy

    B.x,yy,123

    C.xyy123

    D.x,yy

    E.编译失败

    F.运行的时候有异常抛出


    参考答案:B

  • 第2题:

    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:apple

    B.carrot:apple

    C.apple:banana

    D.banana:apple

    E.carrot:carrot

    F.carrot:banana


    参考答案:C

  • 第3题:

    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.1234

    B.10

    C.1,2,3,4

    D.0


    HELLO! HELLO!

  • 第4题:

    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.aAaAaAaAAaaAaA

    C.AAaaAaAaAaaAaA

    D.AaAAAaaaAaAaAa

    E.aAaAaAaAaAAAaa

    F.Anexceptionisthrownatruntime.


    参考答案:C

  • 第5题:

    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 yy

    B.x,yy,123

    C.x yy 123

    D.x,yy


    B