publicclassTest{publicstaticvoidmain(Stringargs){Stringfoo=args[1];Stringbar=args;Stringbaz=args;System.out.printIn(baz=”+baz);}}Andtheoutput:Baz=2Whichcommandlineinvocationwillproducetheoutput?()A.JavaTest2222B.JavaTest1234C.JavaTest4242D.JavaTest4321

题目
publicclassTest{publicstaticvoidmain(Stringargs){Stringfoo=args[1];Stringbar=args;Stringbaz=args;System.out.printIn(baz=”+baz);}}Andtheoutput:Baz=2Whichcommandlineinvocationwillproducetheoutput?()

A.JavaTest2222

B.JavaTest1234

C.JavaTest4242

D.JavaTest4321


相似考题
参考答案和解析
参考答案:C
更多“publicclassTest{publicstaticvoidmain(Stringargs){Stringfoo=args[1];Stringbar=args;Stringbaz=args;System.out.printIn(baz=”+baz);}}Andtheoutput:Baz=2Whichcommandlineinvocationwillproducetheoutput?() ”相关问题
  • 第1题:

    publicclasstest(publicstaticvoidmain(string[]args){stringfoo=args[1];stringfoo=args[2];stringfoo=args[3];})Andcommandlineinvocation:JavaTestredgreenblueWhatistheresult?()

    A.Bazhasthevalueof“”

    B.Bazhasthevalueofnull

    C.Bazhasthevalueof“red”

    D.Bazhasthevalueof“blue”

    E.Baxhasthevalueof“green”

    F.Theprogramthrowsanexception.


    参考答案:F

  • 第2题:

    publicclassTest{publicstaticvoidmain(Stringargs){stringfoo=blue”;stringbar=foo;foo=green”;System.out.printIn(bar);}}Whatistheresult?()

    A.Anexceptionisthrown.

    B.Thecodewillnotcompile.

    C.Theprogramprints“null”

    D.Theprogramprints“blue”

    E.Theprogramprints“green”


    参考答案:D

  • 第3题:

    下面程序执行后,baz的值应是______。 public class Test9 { public static void main(String[] args) { int index = 1; int fox[] = new int [3]; iht bar = fox [index]; int baz = bar + index; System.out.println(baz); } }

    A.0

    B.1

    C.2

    D.编译错误


    正确答案:B
    解析:int fox[]=new int[3]这时数组的每个元素都初始化为0,所以int baz=bar+index;,其实,这时bar的值为0,这样便有baz的值为1。

  • 第4题:

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

  • 第5题:

    publicclasstest(publicstaticvoidmain(stringargs){stringfoo=args[1];stringfoo=args;stringfoo=args;})Andcommandlineinvocation:JavaTestredgreenblueWhatistheresult?()

    A.Bazhasthevalueof“”

    B.Bazhasthevalueofnull

    C.Bazhasthevalueof“red”

    D.Bazhasthevalueof“blue”

    E.Baxhasthevalueof“green”

    F.Theprogramthrowsanexception.


    参考答案:F