itgle.com

publicclassTest{publicenumDogs{collie,harrier,shepherd};publicstaticvoidmain(String[]args){DogsmyDog=Dogs.shepherd;switch(myDog){casecollie:System.out.print(”collie);casedefault:System.out.print(”retriever);caseharrier:System.out.print(”harrier);}}}Whatis

题目

publicclassTest{publicenumDogs{collie,harrier,shepherd};publicstaticvoidmain(String[]args){DogsmyDog=Dogs.shepherd;switch(myDog){casecollie:System.out.print(”collie);casedefault:System.out.print(”retriever);caseharrier:System.out.print(”harrier);}}}Whatistheresult?()

A.harrier

B.shepherd

C.retriever

D.Compilationfails.

E.retrieverharrier

F.Anexceptionisthrownatruntime.


相似考题
更多“publicclassTest{publicenumDogs{collie,harrier,shepherd};publicstaticvoidmain(String[]args) ”相关问题
  • 第1题:

    publicclassTest{publicstaticvoidmain(String[]args){Stringfoo=args[1];Stringbar=args[2];Stringbaz=args[3];System.out.println(baz=+baz);}}Andthecommandlineinvocation:javaTestredgreenblueWhatistheresult?()

    A.baz=

    B.baz=null

    C.baz=blue

    D.Compilationfails.

    E.Anexceptionisthrownatruntime.


    参考答案:E
    Ajava.lang.ArrayIndexOutOfBoundsExceptionisthrownbecauseofline3,shouldbeargs[0].

  • 第2题:

    publicclassTest{publicstaticvoidmain(String[]args){System.out.println(args.length>4&&args[4].equals(-d”));}}Iftheprogramisinvokedusingthecommandline:javaTestOneTwoThree–dWhatistheresult?()

    A.true

    B.false

    C.Compilationfails.

    D.Anexceptionisthrownatruntime.


    参考答案:D
    ThecorrectanswertothisquestionisD.Theargs[4]generatesaruntimeexceptionerrorbecausethereareonly4stringsandtheexpressionargs[4]printsthe5thStringbutlikeitwassaidearlier,thereareonly4strings.

  • 第3题:

    下面的程序会抛出什么异常类型? public class Test { public static void main(String[] args) { Object o = new Object(); String d = (String)o; } }

    A.ArithmeticException

    B.ArrayIndexOutOfBoundsException

    C.StringIndexOutOfBoundsException

    D.ClassCastException


    E

  • 第4题:

    publicclassTest{privatestaticint[]x;publicstaticvoidmain(String[]args){System.out.println(x[0]);}}Whatistheresult?()

    A.0

    B.null

    C.Compilationfails.

    D.ANullPointerExceptionisthrownatruntime.

    E.AnArrayIndexOutOfBoundsExceptionisthrownatruntime.


    参考答案:D

  • 第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)