classTestSuper{22.TestSuper(inti){}3.}4.classTestSubextendsTestSuper{}5.classTestAll{6.publicstaticvoidmain(String[]args){7.newTestSub();8.}9.}Whichistrue?()A.Compilationfails.B.Thecoderunswithoutexception.C.Anexceptionisthrownatline7.D.Anexceptionisthrow

题目
classTestSuper{22.TestSuper(inti){}3.}4.classTestSubextendsTestSuper{}5.classTestAll{6.publicstaticvoidmain(String[]args){7.newTestSub();8.}9.}Whichistrue?()

A.Compilationfails.

B.Thecoderunswithoutexception.

C.Anexceptionisthrownatline7.

D.Anexceptionisthrownatline2.


相似考题
更多“classTestSuper{22.TestSuper(inti){}3.}4.classTestSubextendsTestSuper{}5.classTestAll{6.publicstaticvoidmain(String[]args){7.newTestSub();8.}9.}Whichistrue?() ”相关问题
  • 第1题:

    publicclassAlpha{privatestaticCharacter()ids;publicstaticvoidmain(String[]args){ids=newCharacter[args.length];for(inti=0;iids[i]=newCharacter(args[i]);System.out.print(ids[i]);}}}Whatiscorrect?()

    A.Compilationfails.

    B.Thecoderunswithnooutput.

    C.Anexceptionisthrownatruntime.

    D.Thecoderuns,outputingaconcatenatedlistoftheargumentspassedtotheprogram.


    参考答案:A
    Compilationfails.Line2:ReturnTyperequired.

  • 第2题:

    下列程序段运行的结果为 public class Test{ static void print(String s,int i){ System.out.println("String:"+s+",int:"+i); } static void print(int i, String s){ System.out.println("int:"+i+",String:"+s); } public static void main(String [] args){ print(99,"Int first"); } }

    A.String:Stringfirst,int:11

    B.int:11,String:Int first

    C.String:String first,int:99

    D.int:99,String:int first


    正确答案:D
    解析:本题考查考生阅读程序的能力。JavaApplication都是以main()方法作为入口,首先执行的是print(99,“Intfirst”),根据构造方法的参数类型选择调用方法,这里调用的是print(inti,Strings)方法,因此输出的是int:99,String:Intfirst。

  • 第3题:

    main()方法的正确定义方式是()。

    A.public static void main (String [ ] args ) { new NameSurfer().start (args ) ; }

    B.public static main (String [ ] args ) { new NameSurfer().start (args ) ; }

    C.public void main (String [ ] args ) { new NameSurfer().start (args ) ; }

    D.public static void main (String [ ] args ) { NameSurfer().start (args ) ; }


    public static void main(String[] args) {}

  • 第4题:

    publicclassOuter{2.publicvoidsomeOuterMethod(){3.//Line34.}5.publicclassInner{}6.publicstaticvoidmain(String[]argv){7.Outero=newOuter();8.//Line89. }10. }WhichinstantiatesaninstanceofInner?()

    A.newInner();//Atline3

    B.newInner();//Atline8

    C.newo.Inner();//Atline8

    D.newOuter.Inner();//Atline8


    参考答案:A

  • 第5题:

    以下哪个main方法是正确的?

    A.public static void main(string[] args)

    B.public static void Main(String[] args)

    C.public static void main(String[] args)

    D.public static main(String[] args)

    E.public void main(String[] args)


    public static void main(String[] args)