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.
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.
举一反三
- 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.
- Which statement is true?() A: Compilation succeeds. B: class A does not compile. C: The method declared on line 9 cannot be modified to throw TestException. D: TestA compiles if line 10 is enclosed in try/catch block that catches TestException.
- Java中,下面捕获异常的语句不正确的是( )。 A: try{……}finally{……} B: try{……}catch(Exception ex){……} C: try{ try{……}}catch(Exception ex){……} D: try{ try{……} finally{……}}catch(Exception ex){……}
- 下列哪个是加载JDBC-SQLServer数据库驱动(连接器)(8.0分) A: try{ Class.forName("com.mysql.jdbc.Driver");}catch(Exception e){} B: try{Class.forName("oracle.jdbc.driver.oracleDriver");}catch(Exception e){} C: try{ Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");}catch(Exception e){} D: try{ Class.forName("org.apache.derby.jdbc.EmbeddedDriver");}catch(Exception e){}
- 智慧职教: 现有: 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