import java.io.IOException;   public class ExceptionTest(   public static void main (Stringargs)  try (   methodA();   ) catch (IOException e) (   system.out.printIn(“Caught IOException”);  ) catch (Exception e) (   system.out.printIn(“Caught Exception”);   )   )   public void methodA () {   throw new IOException ();  }     What is the result?()  A、 The code will not compile.B、 The output is caught exception.C、 The output is caught IOException.D、 The program executes normally without printing a message.

import java.io.IOException;   public class ExceptionTest(   public static void main (Stringargs)  try (   methodA();   ) catch (IOException e) (   system.out.printIn(“Caught IOException”);  ) catch (Exception e) (   system.out.printIn(“Caught Exception”);   )   )   public void methodA () {   throw new IOException ();  }     What is the result?()  

  • A、 The code will not compile.
  • B、 The output is caught exception.
  • C、 The output is caught IOException.
  • D、 The program executes normally without printing a message.

相关考题:

下列程序的运行结果是public class test{private String[] data={“10”,“10.5”};public void fun(){double s=0;for(int i=0;i3;i++){try{s=s+Integer .parseInt(data[i]);}catch(Exception e){System.out.print(“errorl:”+data[i]);}}}public static void main(String[]args){try{testd=new test();d .fun();}catch(Exception e){System.out.printIn(“error2”);}}}A.errorl:10.5B.error2C.errorl:10.5 error2D.以上都不对

( 21 )请阅读下面程序import java.io. *;public class ExceptionCatch{public static void main ( String args[] ){try {FileInputStream fis=new FilelnputStream ( "text" ) ;System.out.pfntln ( "content of text is : ” ):} catch ( FileNotFoundException e ){System.out.println ( e ) ;System.out.println ( "message:"+e.getMessageQ ) ;e.printStackTrace ( System.out ) ;}____________;{System.out.println ( e ) ;}}}为保证程序正确运行,程序中下划线处的语句应是A ) catch ( Fiie put eam s )B ) e printStackTrace ()C) catch ( IOException e )D) System.out.printin ( e )

importjava.io.IOException;publicclassExceptionTest(publicstaticvoidmain(String[]args)try(methodA();)catch(IOExceptione)(system.out.printIn(CaughtIOException”);)catch(Exceptione)(system.out.printIn(CaughtException”);))publicvoidmethodA(){thrownewIOException();}Whatistheresult?()A.Thecodewillnotcompile.B.Theoutputiscaughtexception.C.TheoutputiscaughtIOException.D.Theprogramexecutesnormallywithoutprintingamessage.

importjava.io.IOException;publicclassExceptionTest(publicstaticvoidmain(Stringargs)try(methodA();)catch(IOExceptione)(system.out.printIn(CaughtIOException”);)catch(Exceptione)(system.out.printIn(CaughtException”);))publicvoidmethodA(){thrownewIOException();}Whatistheresult?()A.Thecodewillnotcompile.B.Theoutputiscaughtexception.C.TheoutputiscaughtIOException.D.Theprogramexecutesnormallywithoutprintingamessage.

下面程序输出的结果是什么? ( ) 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 throwsExeeption{ static void Proc(intsel) throws Arithmetic Exception,Array Index Out Of Bounds Exception{ System.out.println("InSituation"+sel); if(sel= =0){ System.OUt.println("noException caught"); return; } else if(sel= =l){ int iArray[]=newint[4]; iArray[1]=3; } } public static void main(String args[]){ try{ Proe(O); Proc(1); } catch(Array Index Out Of Bounds Exception e){ System.out.println("Catch"+e); } finally{ System.out.println("inProcfinally"): } } } 执行结果: In Situation 0 no Exception caught in Proc finallyA.In Situation lB.In SituationC.with CatchD.int iArray l

public class foo {   public static void main (stringargs)   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.

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.

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.

public class ExceptionTest {   class TestException extends Exception {}   public void runTest () throws TestException {}   public void test () /* Point X*/ {   runTest ();   }   }   At point X on line 4, which code can be added to make the code compile?()  A、 Throws Exception.B、 Catch (Exception e).C、 Throws RuntimeException.D、 Catch (TestException e).E、 No code is necessary.

现有:  class Flow {  public static void main(String [] args)   try {  System. out .print ("before") ;   doRiskyThing ( )  ;   System.out.print ("after ") ;   } catch (Exception fe) {  System.out.print ("catch") ;   }  System. out .println ( " done") ;  }  public static void doRiskyThing() throws Exception{   // this code returns unless it throws an Exception           }}  可能会产生哪两项结果 ?()  A、 before catchB、 before after doneC、 before catch doneD、 before after catch

class Flow {  public static void main(String [] args) {  try {  System.out.print("before ");  doRiskyThing();  System.out.print("after ");  } catch (Exception fe) {  System.out.print("catch ");  }  System.out.println("done ");  }   public static void doRiskyThing() throws Exception {  // this code returns unless it throws an Exception  } }  可能会产生下面哪两项结果?() A、beforeB、before catchC、before after doneD、before catch done

public class TestA{   public void methodA()  throws IOException{   //……   }   }   public class TestB extends TestA{   public void methodA()  throws EOFException{   //……   }   }   public class TestC extends TestA{   public void methodA()  throws Exception{   //……   }   }   当编译类TestC的时候,结果是哪项?() A、 正常B、 编译错误C、 运行错误D、 以上都不对

现有:  class Birds {  public static void main (String  []  args)  {   try {  throw new Exception () ;    } catch (Exception e) {   try {   throw new Exception () ;  }  catch  (Exception e2)  {  System.out.print ("inner           "); }   System. out.print ( "middle" ) ;    }  System.out.print ("outer") ;    }    }  结果是()A、 inner outerB、 middle outerC、 inner middle outerD、.编译失败

class Birds {  public static void main(String [] args) {  try {  throw new Exception();  } catch (Exception e) { try {  throw new Exception();  } catch (Exception e2) { System.out.print("inner "); }  System.out.print("middle "); }  System.out.print("outer ");  }  }  结果为:()  A、innerB、inner outerC、middle outerD、inner middle outer

11.classa {  12. public void process() { System.out.print(”a,”); } }  13. class b extends a {  14. public void process() throws IOException {  15. super.process();  16. System.out.print(”b,”);  17. throw new IOException();  18. } }  19. public static void main(String[] args) {  20. try { new b().process(); }  21. catch (IOException e) { System.out.println(”Exception”); } }  What is the result?() A、 ExceptionB、 a,b,ExceptionC、 Compilation fails because of an error in line 20.D、 Compilation fails because of an error in line 14.E、 A NullPointerException is thrown at runtime.

1. class Exc0 extends Exception { }  2. class Exc1 extends Exc0 { }  3. public class Test {  4. public static void main(String args[]) {  5. try {  6. throw new Exc1();  7. } catch (Exc0 e0) {  8. System.out.println(“Ex0 caught”);  9. } catch (Exception e) {  10. System.out.println(“exception caught”);  11. }  12. }  13. }  What is the result?()  A、 Ex0 caughtB、 exception caughtC、 Compilation fails because of an error at line 2.D、 Compilation fails because of an error at line 6.

import java.io.IOException;  public class ExceptionTest(  public static void main (String[]args)  try (  methodA();  ) catch (IOException e)  (  system.out.printIn(“Caught IOException”);  ) catch (Exception e)   (  system.out.printIn(“Caught Exception”);  )  )  public void methodA ()   {  throw new IOException ();  }   What is the result?() A、 The code will not compile.B、 The output is caught exception.C、 The output is caught IOException.D、 The program executes normally without printing a message.

单选题现有:  class Birds {  public static void main (String  []  args)  {   try {  throw new Exception () ;    } catch (Exception e) {   try {   throw new Exception () ;  }  catch  (Exception e2)  {  System.out.print ("inner           "); }   System. out.print ( "middle" ) ;    }  System.out.print ("outer") ;    }    }  结果是()A inner outerB middle outerC inner middle outerD.编译失败

单选题import java.io.IOException;  public class ExceptionTest(  public static void main (String[]args)  try (  methodA();  ) catch (IOException e)  (  system.out.printIn(“Caught IOException”);  ) catch (Exception e)   (  system.out.printIn(“Caught Exception”);  )  )  public void methodA ()   {  throw new IOException ();  }   What is the result?()A The code will not compile.B The output is caught exception.C The output is caught IOException.D The program executes normally without printing a message.

单选题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.

多选题class Order implements Runnable {  public void run() {  try { Thread.sleep(2000); } catch (Exception e) { }  System.out.print("in ");  }  public static void main(String [] args) {  Thread t = new Thread(new Order());  t.start();  System.out.print("pre ");  try { t.join(); } catch (Exception e) { }  System.out.print("post ");  } }  可产生哪两项结果?()Ain preBpre inCin pre postDpre in post

单选题public class foo {   public static void main (stringargs)   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.

单选题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.

单选题1. class Exc0 extends Exception { }  2. class Exc1 extends Exc0 { }  3. public class Test {  4. public static void main(String args[]) {  5. try {  6. throw new Exc1();  7. } catch (Exc0 e0) {  8. System.out.println(“Ex0 caught”);  9. } catch (Exception e) {  10. System.out.println(“exception caught”);  11. }  12. }  13. }  What is the result?()A Ex0 caughtB exception caughtC Compilation fails because of an error at line 2.D Compilation fails because of an error at line 6.

单选题public class ExceptionTest {  class TestException extends Exception {}  public void runTest () throws TestException {}  public void test () /* Point X*/  {  runTest ();  }  }   At point X on line 4, which code can be added to make the code compile?()A Throws Exception.B Catch (Exception e).C Throws RuntimeException.D Catch (TestException e).E No code is necessary.

单选题import java.io.IOException;   public class ExceptionTest(   public static void main (Stringargs)  try (   methodA();   ) catch (IOException e) (   system.out.printIn(“Caught IOException”);  ) catch (Exception e) (   system.out.printIn(“Caught Exception”);   )   )   public void methodA () {   throw new IOException ();  }     What is the result?()A The code will not compile.B The output is caught exception.C The output is caught IOException.D The program executes normally without printing a message.