itgle.com

Given:Andthefollowingfivefragments:publicstaticvoidmain(String...a){publicstaticvoidmain(String.*a){publicstaticvoidmain(String...a){publicstaticvoidmain(String[]...a){publicstaticvoidmain(String...[]a){Howmanyofthecodefragments,insertedindependentlyatlin

题目

Given:Andthefollowingfivefragments:publicstaticvoidmain(String...a){publicstaticvoidmain(String.*a){publicstaticvoidmain(String...a){publicstaticvoidmain(String[]...a){publicstaticvoidmain(String...[]a){Howmanyofthecodefragments,insertedindependentlyatline2,compile?()

A.0

B.1

C.2

D.3

E.4


相似考题
更多“Given:Andthefollowingfivefragments:publicstaticvoidmain(String...a){publicstaticvoidmain(S ”相关问题
  • 第1题:

    classMineral{staticStringshiny(){return"1";}}classGraniteextendsMineral{publicstaticvoidmain(String[]args){Strings=shiny()+getShiny();s=s+super.shiny();System.out.println(s);}staticStringgetShiny(){returnshiny();}}结果为:()

    A.3

    B.12

    C.111

    D.编译失败


    参考答案:D

  • 第2题:

    importjava.util.*;classScanStuff{publicstaticvoidmain(String[]args){Strings="x,yy,123";Scannersc=newScanner(s);while(sc.hasNext())System.out.print(sc.next()+"");}}结果是什么?()

    A.xyy

    B.x,yy

    C.xyy123

    D.x,yy,123


    参考答案:D

  • 第3题:

    interfaceDeclareStuff{publicstaticfinalintEASY=3;voiddoStuff(intt);}publicclassTestDeclareimplementsDeclareStuff{publicstaticvoidmain(String[]args){intx=5;newTestDeclare().doStuff(++x);}voiddoStuff(ints){s+=EASY+++s;System.out.println(”s+s);}}Whatistheresult?()

    A.s14

    B.s16

    C.s10

    D.Compilationfails.

    E.Anexceptionisthrownatruntime.


    参考答案:D

  • 第4题:

    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(ix>0)System.out.println(args[ix]);

    }

    CODEFRAGMENTe:

    publicstaticvoidmain(Stringargs[]){

    try{System.out.println(args[args.length-1]);

    }catch(NullPointerExceptione){}

    }


    参考答案:A

  • 第5题:

    IfthissourcecodeiscontainedinafilecalledSmallProg.java,whatcommandshouldbeusedtocompileitusingtheJDK?()publicclassSmallProg{publicstaticvoidmain(Stringargs[]){System.out.println("Goodluck!");}}

    A.javaSmallProg

    B.avacSmallProg

    C.javacSmallProg.java

    D.javaSmallProgmain


    参考答案:C

  • 第6题:

    publicclassfoo{staticStrings;publicstaticvoidmain(String[]args){system.out.printIn(s=”+s);}}Whatistheresult?()

    A.Thecodecompilesand“s=”isprinted.

    B.Thecodecompilesand“s=null”isprinted.

    C.Thecodedoesnotcompilebecausestringsisnotinitialized.

    D.Thecodedoesnotcompilebecausestringscannotbereferenced.

    E.Thecodecompiles,butaNullPointerExceptionisthrownwhentoStringiscalled.


    参考答案:B

  • 第7题:

    publicclassFoo{publicstaticvoidmain(String[]args){try{return;}finally{System.out.println(Finally”);}}}Whatistheresult?()

    A.Finally

    B.Compilationfails.

    C.Thecoderunswithnooutput.

    D.Anexceptionisthrownatruntime.


    参考答案:A

  • 第8题:

    publicclassX{publicstaticvoidmain(Stringargs){Strings1=newString(true”);Booleanb1=newBoolean(true);if(s2.equals(b1)){System.out.printIn(Equal”);}}}Whatistheresult?()

    A.Theprogramrunsandprintsnothing.

    B.Theprogramrunsandprints“Equal”

    C.Anerroratline5causescompilationtofail.

    D.Theprogramrunsbutabortswithanexception.


    参考答案:A

  • 第9题:

    publicclassfoo{publicstaticvoidmain(Stringargs){Strings;system.out.printIn(s=”+s);}}Whatistheresult?()

    A.Thecodecompilesand“s=”isprinted.

    B.Thecodecompilesand“s=null”isprinted.

    C.Thecodedoesnotcompilebecausestringsisnotinitialized.

    D.Thecodedoesnotcompilebecausestringscannotbereferenced.

    E.Thecodecompiles,butaNullPointerExceptionisthrownwhentoStringiscalled.


    参考答案:C

  • 第10题:

    Given:11.staticclassA{12.voidprocess()throwsException{thrownewException();}13.}14.staticclassBextendsA{15.voidprocess(){System.out.println("B");}16.}17.publicstaticvoidmain(String[]args){18.Aa=newB();19.a.process();20.}Whatistheresult?()

    A.Compilationfailsbecauseofanerrorinline19.

    B.Anexceptionisthrownatruntime.

    C.B

    D.Compilationfailsbecauseofanerrorinline18.

    E.Compilationfailsbecauseofanerrorinline15.

    F.Thecoderunswithnooutput.


    参考答案:A

  • 第11题:

    main方法是javaapplication程序执行的入口点,关于main方法的方法头,以下()是合法的。

    A.publicstaticvoidmain()

    B.publicstaticvoidmain(Stringargs[])

    C.publicstaticintmain(string[]arg)

    D.publicvoidmain(stringarg[])


    正确答案:B

  • 第12题:

    填空题
    下列程序的运行结果是() classProgramx=0,y=-1; { publicstaticvoidMain(string[]args) { int i=0,s=1; do{s/=s+1;i++; } while(i<=10); Console.WriteLine(“i={0},s={1}”,i,s);

    正确答案: i=11,s=12
    解析: 暂无解析

  • 第13题:

    finalclassTree{privatestaticStringtree="tree";StringgetTree(){returntree;}}classElmextendsTree{privatestaticStringtree="elm";publicstaticvoidmain(String[]args){newElm().go(newTree());}voidgo(Treet){Strings=t.getTree()+Elm.tree+tree+(newElm().getTree());System.out.println(s);}}结果为:()

    A.elmelmelmelm

    B.treeelmelmelm

    C.treeelmtreeelm

    D.编译失败


    参考答案:D

  • 第14题:

    现有:

    classTree{

    privatestaticStringtree="tree";

    StringgetTree(){returntree;}

    }

    classElmextendsTree{

    privatestaticStringtree="elm";

    publicstaticvoidmain(String[]args){

    newElm().go(newTree());

    }

    }

    voidgo(Treet){

    Strings=t.getTree()+Elm.tree+tree+(newElm().getTree());

    System.out.println(s);}

    结果为:()


    参考答案:C

  • 第15题:

    publicclassTest{publicstaticvoidmain(String[]args){booleanassert=true;if(assert){System.out.println(”assertistrue”);}}}Given:javac-source1.3Test.javaWhatistheresult?()

    A.Compilationfails.

    B.Compilationsucceedswitherrors.

    C.Compilationsucceedswithwarnings.

    D.Compilationsucceedswithoutwarningsorerrors.


    参考答案:C

  • 第16题:

    Whatwillbewrittentothestandardoutputwhenthefollowingprogramisrun?()publicclassQd803{publicstaticvoidmain(Stringargs[]){Stringword="restructure";System.out.println(word.substring(2,3));}}

    A.est

    B.es

    C.str

    D.st

    E.s


    参考答案:E

  • 第17题:

    publicclassX{publicstaticvoidmain(String[]args){strings=newstring(Hello”);modify(s);System.out.printIn(s);}publicstaticvoidmodify(Strings){s+=world!”;}}Whatistheresult?()

    A.Theprogramrunsandprints“Hello”

    B.Anerrorcausescompilationtofail.

    C.Theprogramrunsandprints“Helloworld!”

    D.Theprogramrunsbutabortswithanexception.


    参考答案:A

  • 第18题:

    publicclassTest{publicstaticvoidmain(String[]args){Stringstr=NULL;System.out.println(str);}}Whatistheresult?()

    A.NULL

    B.Compilationfails.

    C.Thecoderunswithnooutput.

    D.Anexceptionisthrownatruntime.


    参考答案:B

    NULLshouldbe"null".

  • 第19题:

    publicclassX{publicstaticvoidmain(Stringargs){strings=newstring(Hello”);modify(s);System.out.printIn(s);}publicstaticvoidmodify(Strings){s+=world!”;}}Whatistheresult?()

    A.Theprogramrunsandprints“Hello”

    B.Anerrorcausescompilationtofail.

    C.Theprogramrunsandprints“Helloworld!”

    D.Theprogramrunsbutabortswithanexception.


    参考答案:A

  • 第20题:

    Given:310-025LeadingthewayinITtestingandcertificationtools,www.testking.com-48-publicclassfoo{staticStrings;publicstaticvoidmain(Stringargs){system.out.printIn(s=”+s);}}Whatistheresult?()

    A.Thecodecompilesand“s=”isprinted.

    B.Thecodecompilesand“s=null”isprinted.

    C.Thecodedoesnotcompilebecausestringsisnotinitialized.

    D.Thecodedoesnotcompilebecausestringscannotbereferenced.

    E.Thecodecompiles,butaNullPointerExceptionisthrownwhentoStringiscalled.


    参考答案:B

  • 第21题:

    下面程序的运行结果是____________。publicclassAbc{publicstaticvoidmain(Stringargs[]){intb=5;for(inti=0;i<2;i++){b=b+i}System.out.println(“b=“+b);}}


    参考答案:b=6

  • 第22题:

    Given:11.publicstaticvoidmain(String[]args){12.Objectobj=newint[]{1,2,3};13.int[]someArray=(int[])obj;14.for(inti:someArray)System.out.print(i+"");15.}Whatistheresult?()

    A.Compilationfailsbecauseofanerrorinline13.

    B.AClassCastExceptionisthrownatruntime.

    C.123

    D.Compilationfailsbecauseofanerrorinline14.

    E.Compilationfailsbecauseofanerrorinline12.


    参考答案:C

  • 第23题:

    下列程序的运行结果是() classProgramx=0,y=-1; { publicstaticvoidMain(string[]args) { int i=0,s=1; do{s/=s+1;i++; } while(i<=10); Console.WriteLine(“i={0},s={1}”,i,s);


    正确答案:i=11,s=12