【单选题】下面的程序段执行结果是()。 public class None { public static void main(String[] args) { try{ return; }finally { System.out.println("finally"); } } }A.编译通过,但运行时出现异常B.程序正常运行,不输出任何结果C.程序正常运行,并输出“finally”D.因为没有catch语句,编译错误
【单选题】下面的程序段执行结果是()。 public class None { public static void main(String[] args) { try{ return; }finally { System.out.println("finally"); } } }
A.编译通过,但运行时出现异常
B.程序正常运行,不输出任何结果
C.程序正常运行,并输出“finally”
D.因为没有catch语句,编译错误
参考答案和解析
D
相关考题:
下列程序的运行结果是【 】。public class Test {public static void main (String args[]) {String s1="hello!";System.out.println (s1.toUpperCase());}}
( 8 )阅读下列代码public class Test2{public static void main(String args[]){System.out.println(5/2);}}其执行结果是 【 8 】 。
下面程序段的输出结果是( )。 public class Test { public static void main (String[] args) { for ( int a=0;a<10;a++) { if (a==5) break; System.out.println(A); } } }A.01234B.6789C.012346789D.5
下列程序的执行结果是 public class Testaa { public static void main(String args[ ]) { System.out.println(5/2); } }A.2.5B.2C.2.5D.2
下面程序的执行结果是______。 public class ex27 { public static void main(String[] args) { try { return; } finally { System. out. print in ( "Finally" ); } }A.程序正常运行,并输出FinallyB.程序正常运行,但不输出任何结果C.编译能通过,但运行时会出现一个异常D.因为没有catch字句,所以不能通过编译
下面程序输出的结果是什么? ( ) public class Quiz2 { public static void main(String args[]) { try {throw new MyException(); }catch(Exception e) { System.out.println("It's caught!"); }finally{ System.out.println("It's finally caught!"); } } } class MyException extends Exception{}A.It's finally caught!B.It's caught!C.It's caught!/It's finally caught!D.无输出
下面程序输出的结果是什么? ( ) public class Quiz2 { public static void main(String args[]) { try {throw new MyException(); }catch(Exception e) { System.out.println("It's caught!"); }finally{ System.out.println("It's finally caught!"); } } } class MyExeeption extends Exception{}A.It's finally caught!B.It's caught!C.It's caught!/It'sfinally caught!D.无输出
下列程序创建了一个线程并运行,请在下划线处填入正确代码。public class Try extends Thread{public static void main(String args[]){Threadt=new Try();【 】;}public void run(){System.out.println(“Try!”);}}
分析下列代码: Class A{ Public static void main(String[] args){ method(); } static void method(){ try{ System.out.println("Hello"); }finally{ System.out.println("good-bye"); } } } 编译运行后,输出结果是()。 A、"Hello"B、"good-bye"C、"Hello""god-bye"D、代码不能编译
Which declarations will allow a class to be started as a standalone program?() A、public void main(String args[])B、public void static main(String args[])C、public static main(String[] argv)D、final public static void main(String [] array)E、public static void main(String args[])
public class foo { public static void main (string[]args) try {return;} finally {system.out.printIn(“Finally”);} } What is the result?()A、 The program runs and prints nothing.B、 The program runs and prints “Finally”C、 The code compiles, but an exception is thrown at runtime.D、 The code will not compile because the catch block is missing.
static void test() { try { String x=null; System.out.print(x.toString() +“ “); } finally { System.out.print(“finally “); } } public static void main(String[] args) { try { test(); } catch (Exception ex) { System.out.print(”exception “); } } What is the result?() A、 nullB、 finallyC、 null finallyD、 Compilation fails.E、 finally exception
分析下列Java代码: class A { public static void main(String[] args) { method(); } static void method() { try { System.out.println("Hello"); System.exit(0); } finally { System.out.println("good-bye"); } } } 编译运行后,输出结果是()。 A、"Hello"B、"good-bye"C、"Hello"后面是"good-bye"D、代码不能编译
public class Test { public static void aMethod() throws Exception { try { throw new Exception(); } finally { System.out.println(“finally”); } } public static void main(String args[]) { try { aMethod(); } catch (Exception e) { System.out.println(“exception”); } System.out.println(“finished”); } } What is the result?() A、 finallyB、 exception finishedC、 finally exception finishedD、 Compilation fails.
分析下列java代码 Class A{ Public static void main(String[] args){ Method(); } Static void method(){ try{ System.out.println(“hello”) }finally{ System.out.println(“good-bye”); } } } 编译运行后,输出结果是()A、“hello”B、“good-bye”C、“hello”“good-bye”D、代码不能编译
public class X { public static void main(String [] args) { try { badMethod(); System.out.print(“A”); } catch (Exception ex) { System.out.print(“B”); } finally { System.out.print(“C”); } System.out.print(“D”); } public static void badMethod() {} } What is the result?() A、 ACB、 BDC、 ACDD、 ABCDE、 Compilation fails.
public class Foo { public static void main(String[] args) { try { return; } finally { System.out.println( “Finally” ); } } } What is the result?()A、 FinallyB、 Compilation fails.C、 The code runs with no output.D、 An exception is thrown at runtime.
Given 1. public class Foo { 2. public static void main (String [] args) } 3. try { return;} 4. finally { Syste.out.printIn (“Finally”);} 5. } 6. } What is the result( )?A、 The program runs and prints nothing.B、 The program runs and prints “Finally”.C、 The code comiles. But an exception is thrown at runtime.D、 The code will not compile because the catch block is missing.
下面哪些main方法可用于程序执行()A、public static void main(String[]args)B、public static void main(String[]x)C、public static void main(Stringargs[])D、public void main(String[]args)
单选题public class Test { public static void aMethod() throws Exception { try { throw new Exception(); } finally { System.out.println(“finally”); } } public static void main(String args[]) { try { aMethod(); } catch (Exception e) { System.out.println(“exception”); } System.out.println(“finished”); } } What is the result?()A finallyB exception finishedC finally exception finishedD Compilation fails.
单选题分析下列Java代码: class A { public static void main(String[] args) { method(); } static void method() { try { System.out.println("Hello"); System.exit(0); } finally { System.out.println("good-bye"); } } } 编译运行后,输出结果是()。AHelloBgood-byeCHello后面是good-byeD代码不能编译
单选题Given 1. public class Foo { 2. public static void main (String [] args) } 3. try { return;} 4. finally { Syste.out.printIn (“Finally”);} 5. } 6. } What is the result( )?A The program runs and prints nothing.B The program runs and prints “Finally”.C The code comiles. But an exception is thrown at runtime.D The code will not compile because the catch block is missing.
单选题分析下列代码: Class A{ Public static void main(String[] args){ method(); } static void method(){ try{ System.out.println("Hello"); }finally{ System.out.println("good-bye"); } } } 编译运行后,输出结果是()。AHelloBgood-byeCHellogod-byeD代码不能编译
单选题public class Foo { public static void main(String[] args) { try { return; } finally { System.out.println( “Finally” ); } } } What is the result?()A FinallyB Compilation fails.C The code runs with no output.D An exception is thrown at runtime.
单选题public class foo { public static void main (string[]args) try {return;} finally {system.out.printIn(“Finally”);} } What is the result?()A The program runs and prints nothing.B The program runs and prints “Finally”C The code compiles, but an exception is thrown at runtime.D The code will not compile because the catch block is missing.
单选题static void test() { try { String x=null; System.out.print(x.toString() +“ “); } finally { System.out.print(“finally “); } } public static void main(String[] args) { try { test(); } catch (Exception ex) { System.out.print(”exception “); } } What is the result?()A nullB finallyC null finallyD Compilation fails.E finally exception
单选题分析下列java代码 Class A{ Public static void main(String[] args){ Method(); } Static void method(){ try{ System.out.println(“hello”) }finally{ System.out.println(“good-bye”); } } } 编译运行后,输出结果是()A“hello”B“good-bye”C“hello”“good-bye”D代码不能编译
单选题public class X { public static void main(String [] args) { try { badMethod(); System.out.print(“A”); } catch (Exception ex) { System.out.print(“B”); } finally { System.out.print(“C”); } System.out.print(“D”); } public static void badMethod() {} } What is the result?()A ACB BDC ACDD ABCDE Compilation fails.