publicclassTest{publicenumDogs{collie,harrier};publicstaticvoidmain(String[]args){DogsmyDog=Dogs.collie;switch(myDog){casecollie:System.out.print(”collie);caseharrier:System.out.print(”harrier);}}}Whatistheresult?()
A.collie
B.harrier
C.Compilationfails.
D.collieharrier
E.Anexceptionisthrownatruntime.
第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.
第2题:
A.true
B.false
C.Compilationfails.
D.Anexceptionisthrownatruntime.
第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
第4题:
A.0
B.null
C.Compilationfails.
D.ANullPointerExceptionisthrownatruntime.
E.AnArrayIndexOutOfBoundsExceptionisthrownatruntime.
第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)