Which is the correct statement about the throw statement?
A: The throw statement allows the code to explicitly throw an exception.
B: throw exception expression; It raises an exception which is an arbitrary value.
C: throw; can exist in the catch block, as well as in the try and finally blocks.
D: throw; can only be used in catch blocks to ignore the exception currently being handled by the catch block.
A: The throw statement allows the code to explicitly throw an exception.
B: throw exception expression; It raises an exception which is an arbitrary value.
C: throw; can exist in the catch block, as well as in the try and finally blocks.
D: throw; can only be used in catch blocks to ignore the exception currently being handled by the catch block.
举一反三
- Which of the following statements is true? ( ) A: The catch block contains the code that might throw an exception. B: The try block contains the code that handles the exception if one occurs. C: You can have many catch blocks to handle different types of exceptions. D: When a try block terminates, any variables declared in the try block are preserved.
- 智慧职教: 现有: 1. class Birds { 2. public static void main (String [] args) { 3. try { 4. throw new Exception () ; 5. } catch (Exception e) { 6. try { 7. throw new Exception () ; 8. } catch (Exceptio
- 下面语句中不存在语法错误的选项是( )。 A: throw new NullPointerException(); B: throw “Exception”; C: throw new Exception(); D: throw new IOException();
- 阅读以下程序class Test{static void F(){try{G();}Catch(Exception e){Console.Write(e.Message);e = new Exception(“F”);throw;}}static void G(){throw new Exception(“G”);}static void Main(){try{F();}catch(Exception e){Console.Write (e.Message);}}}以上程序运行的结果是() A: F F B: F G C: G G D: G F
- P10: In Java, ______ produces an exception to stop calling stack and redirects program execution to the first catch block. A: Throw B: This C: New D: Implements