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


相关考题:

以下是JAVA中正确的入口方法是?() A.publicstaticvoidmain(String[]args){}B.publicstaticvoidmain(Stringargs){}C.publicvoidmain(String[]args){}D.publicstaticintmain(String[]args){}

Whichcodefragmentswillsucceedinprintingthelastargumentgivenonthecommandlinetothestandardoutput,andexitgracefullywithnooutputifnoargumentsaregiven?()CODEFRAGMENTa:publicstaticvoidmain(Stringargs[]){if(args.length!=0)System.out.println(args[args.length-1]);}CODEFRAGMENTb:publicstaticvoidmain(Stringargs[]){try{System.out.println(args[args.length]);}catch(ArrayIndexOutOfBoundsExceptione){}}CODEFRAGMENTc:publicstaticvoidmain(Stringargs[]){intix=args.length;Stringlast=args[ix];if(ix!=0)System.out.println(last);}CODEFRAGMENTd:publicstaticvoidmain(Stringargs[]){intix=args.length-1;if(ix0)System.out.println(args[ix]);}CODEFRAGMENTe:publicstaticvoidmain(Stringargs[]){try{System.out.println(args[args.length-1]);}catch(NullPointerExceptione){}}

publicclassTest{publicstaticvoidmain(String[]args){stringfoo=blue”;stringbar=foo;foo=green”;System.out.printIn(bar);}}Whatistheresult?() A.Anexceptionisthrown.B.Thecodewillnotcompile.C.Theprogramprints“null”D.Theprogramprints“blue”E.Theprogramprints“green”

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

publicclasstest(publicstaticvoidmain(string[]args){stringfoo=args[1];stringfoo=args[2];stringfoo=args[3];})Andcommandlineinvocation:JavaTestredgreenblueWhatistheresult?() A.Bazhasthevalueof“”B.BazhasthevalueofnullC.Bazhasthevalueof“red”D.Bazhasthevalueof“blue”E.Baxhasthevalueof“green”F.Theprogramthrowsanexception.

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

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”

publicclasstest(publicstaticvoidmain(stringargs){stringfoo=args[1];stringfoo=args;stringfoo=args;})Andcommandlineinvocation:JavaTestredgreenblueWhatistheresult?() A.Bazhasthevalueof“”B.BazhasthevalueofnullC.Bazhasthevalueof“red”D.Bazhasthevalueof“blue”E.Baxhasthevalueof“green”F.Theprogramthrowsanexception.

下面程序执行后,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.0B.1C.2D.编译错误