niusouti.com

publicclassFoo{publicstaticvoidmain(String[]args){try{return;}finally{System.out.println(Finally”);}}}Whatistheresult?()A.FinallyB.Compilationfails.C.Thecoderunswithnooutput.D.Anexceptionisthrownatruntime.

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

A.Finally

B.Compilationfails.

C.Thecoderunswithnooutput.

D.Anexceptionisthrownatruntime.


相似考题
参考答案和解析
参考答案:A
更多“publicclassFoo{publicstaticvoidmain(String[]args){try{return;}finally{System.out.println(Finally”);}}}Whatistheresult?() ”相关问题
  • 第1题:

    publicclassfoo{publicstaticvoidmain(stringargs)try{return;}finally{system.out.printIn(Finally”);}}Whatistheresult?()

    A.Theprogramrunsandprintsnothing.

    B.Theprogramrunsandprints“Finally”

    C.Thecodecompiles,butanexceptionisthrownatruntime.

    D.Thecodewillnotcompilebecausethecatchblockismissing.


    参考答案:B

  • 第2题:

    运行以下程序时,控制台上显示什么? public class Test { public static void main (String[] args) { try { System.out.println("Welcome to Java"); return; } finally { System.out.println("The finally clause is executed"); } } }

    A.Welcome to Java

    B.Welcome to Java 和 The finally clause is executed

    C.The finally clause is executed

    D.什么都不输出


    以上都不对

  • 第3题:

    【单选题】下面程序段的执行结果是什么?   public class Foo{    public static void main(String[] args){     try{       return;}       finally{System.out.println("Finally");      }    }   }

    A.编译能通过,但运行时会出现一个例外。

    B.程序正常运行,并输出 "Finally"。

    C.程序正常运行,但不输出任何结果。 

    D.因为没有catch语句块,所以不能通过编译。


    14

  • 第4题:

    下面程序段的执行结果是()。 public class Foo{ public static void main(String[] args){ try{ return; } finally { System.out.println("Finally!");} } }

    A.程序正常运行,但不输出任何结果

    B.程序正常运行,并输出Finally!

    C.编译能通过,但运行时会出现例外

    D.因为没有catch语句块,所以不能通过编译


    B

  • 第5题:

    下面的程序段执行结果是 public class Foo { public static void main(String[] args) { try{ return; }finally { System.out.println("finally"); } } }

    A.编译通过,但运行时出现异常

    B.程序正常运行,不输出任何结果

    C.程序正常运行,并输出“finally”

    D.因为没有catch语句,编译错误


    B