可以在第1行插入哪个代码片段来编译代码?
A: finally { in. close(); }
B: catch (FileNotFoundException | Exception e) { } finally { in. close(); }
C: catch (Exception e) { }
D: catch (Exception I IOExcepti e) { }
E: catch (FileNotFoundException e) { }
A: finally { in. close(); }
B: catch (FileNotFoundException | Exception e) { } finally { in. close(); }
C: catch (Exception e) { }
D: catch (Exception I IOExcepti e) { }
E: catch (FileNotFoundException e) { }
举一反三
- 下列哪个是加载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){}
- Java中,下面捕获异常的语句不正确的是( )。 A: try{……}finally{……} B: try{……}catch(Exception ex){……} C: try{ try{……}}catch(Exception ex){……} D: try{ try{……} finally{……}}catch(Exception ex){……}
- 程序员将可能发生异常的代码放在( )语句块中,后面紧跟着一个或多个( )语句块,还可以再跟零个或一个( )语句块。 A: catch、try 、finally B: try、catch 、finally C: try、finally、exception D: exception、try、finally
- public void test() { try { oneMethod(); Console.WriteLine("condition 1"); } catch (ArrayIndexOutOfBoundsException e) { Console.WriteLine ("condition 2"); } catch(Exception e) { Console.WriteLine ("condition 3"); } finally { Console.WriteLine ("finally"); } } 在oneMethod()方法运行正常的情况下将显示( )( 3 分)
- 下面的代码是连接哪个数据库的驱动加载片段( ) try{ Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver"); } catch(Exception e){ out.print(e.toString()); }