Given1.publicclassFoo{2.publicstaticvoidmain(String[]args)}3.try{return;}4.finally{Syste.out.printIn(Finally”);}5.}6.}Whatistheresult()?A.Theprogramrunsandprintsnothing.B.Theprogramrunsandprints“Finally”.C.Thecodecomiles.Butanexceptionisthrownatruntime.D.

题目
Given1.publicclassFoo{2.publicstaticvoidmain(String[]args)}3.try{return;}4.finally{Syste.out.printIn(Finally”);}5.}6.}Whatistheresult()?

A.Theprogramrunsandprintsnothing.

B.Theprogramrunsandprints“Finally”.

C.Thecodecomiles.Butanexceptionisthrownatruntime.

D.Thecodewillnotcompilebecausethecatchblockismissing.


相似考题
更多“Given1.publicclassFoo{2.publicstaticvoidmain(String[]args)}3.try{return;}4.finally{Syste.out.printIn(Finally”);}5.}6.}Whatistheresult()? ”相关问题
  • 第1题:

    staticvoidtest(){try{Stringx=null;System.out.print(x.toString()+);}finally{System.out.print(finally);}}publicstaticvoidmain(String[]args){try{test();}catch(Exceptionex){System.out.print(”exception);}}Whatistheresult?()

    A.null

    B.finally

    C.nullfinally

    D.Compilationfails.

    E.finallyexception


    参考答案:E

  • 第2题:

    publicclassX{2.publicstaticvoidmain(String[]args){3.int[]a=newint[1]4.modify(a);5.System.out.printIn(a[0]);6.}7.8.publicstaticvoidmodify(int[]a){9.a[0]++;10.}11.}Whatistheresult?()

    A.Theprogramrunsandprints“0”

    B.Theprogramrunsandprints“1”

    C.Theprogramrunsbutabortswithanexception.

    D.Anerror“possibleundefinedvariable”atline4causescompilationtofail.

    E.Anerror“possibleundefinedvariable”atline9causescompilationtofail.


    参考答案:B

  • 第3题:

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

    A.Finally

    B.Compilationfails.

    C.Thecoderunswithnooutput.

    D.Anexceptionisthrownatruntime.


    参考答案:A

  • 第4题:

    publicstaticvoidparse(Stringstr){try{floatf=Float.parseFloat(str);}catch(NumberFormatExceptionnfe){f=0;}finally{System.out.println(f);}}publicstaticvoidmain(String[]args){parse(”invalid”);}Whatistheresult?()

    A.0.0

    B.Compilationfails.

    C.AParseExceptionisthrownbytheparsemethodatruntime.

    D.ANumberFormatExceptionisthrownbytheparsemethodatruntime.


    参考答案:B

  • 第5题:

    publicclassfoo{publicstaticvoidmain(string[]args)try{return;}finally{system.out.printIn(Finally”);}}Whatistheresult?()

    A.Theprogramrunsandprintsnothing.

    B.Theprogramrunsandprints“Finally”

    C.Thecodecompiles,butanexceptionisthrownatruntime.

    D.Thecodewillnotcompilebecausethecatchblockismissing.


    参考答案:B