网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)

下面的代码是连接哪个数据库的驱动程序加载片段:() try{ Class.forName(com.mysql.jdbc.Driver );} catch(Exception e){ out.print(e.toString());}

A.Oracle

B.Sql Server

C.Mysql

D.不确定


参考答案和解析
Oracle
更多 “下面的代码是连接哪个数据库的驱动程序加载片段:() try{ Class.forName(com.mysql.jdbc.Driver );} catch(Exception e){ out.print(e.toString());}A.OracleB.Sql ServerC.MysqlD.不确定” 相关考题
考题 阅读下列程序片段。Public void test{Try{sayHello;system.out.println(hello):}catch(ArraylndexOutOfBoundException e){System.out.println(ArraylndexOutOfBoundExcep—tion);}catch(Exception e){System.out.println(Exception):}finally{System.Out.println(finally);}}如果sayHello方法正常运行,则test方法的运行结果将是( )。A.HelloB.ArraylndexOutOfBondsExceptionC.ExceptionFinallyD.HelloFinally

考题 下列关于try和catch语句的描述中,错误的是______。A.不同的catch代码段是不同的作用域,但是可以访问相互之间定义的局部变量B.如果没有异常产生,则所有的catch代码段都被略过不执行C.异常总是由距离产生异常最近的匹配catch代码段处理D.try代码段后跟一个或多个catch代码段

考题 这段代码有什么不足之处?try {Connection conn = ...;Statement stmt = ...;ResultSet rs = stmt.executeQuery("select * from table1");while(rs.next()) {}} catch(Exception ex) {}

考题 阅读下列程序片段。 Public void test{ Try{ sayHello; system.out.println("hello"): }catch(ArraylndexOutOfBoundException e){ System.out.println("ArraylndexOutOfBoundExcep— tion"); }catch(Exception e){ System.out.println("Exception"): }finally{ System.Out.println("finally"); } } 如果sayHello方法正常运行,则test方法的运行结果将是( )。A.HelloB.ArraylndexOutOfBondsExceptionC.Exception FinallyD.Hello Finally

考题 阅读下列程序片段 Publicvoidtest(){ Try{ sayHello(); system.out.println(“hello"); }catch(ArrayIndexOutOfBoundExceptione){ System.out.println(“ArraylndexOutOfBoundException”); }catch(Exceptione){ System.out.println(“Exception”); }finally{ System.out.println(“finally”); } } 如果sayHello()方法正常运行,则test()方法的运行结果将是( )。A.HelloB.ArraylndexOutOfBondsExceptionC.Exception FinallyD.Hello Finally

考题 static void test() throws RuntimeException {  try {  System.out.print(”test “);  throw new RuntimeException();  }  catch (Exception ex) { System.out.print(”exception “); }  }  public static void main(String[] args) {  try { test(); }  catch (RuntimeException ex) { System.out.print(”runtime “); }  System.out.print(”end “);  }  What is the result?() A、 test endB、 Compilation fails.C、 test runtime endD、 test exception endE、 A Throwable is thrown by main at runtime.

考题 JDBC加载不同数据库的驱动程序,使用相应的参数可以建立与各种数据库的连接。

考题 如下代码:  public void Test() { try {  oneMethod();  System.out.println("condition 1");  } catch (ArrayIndexOutOfBoundsException e) {  System.out.println("condition 2");  } catch(Exception e) {  System.out.println("condition 3"); } finally {  System.out.println("finally"); }   }  如果oneMethod正常运行,则输出结果中是?()A、 condition 1   finallyB、 condition 2   finallyC、 condition 3   finallyD、 finally

考题 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

考题 关于JDBC访问数据库的说法错误的是:()A、 建立数据库连接时,必须加载驱动程序,可采用Class.forName()实现B、 用于建立与某个数据源的连接可采用DriverManager类的getConnection方法C、 建立数据库连接时,必须要进行异常处理D、 JDBC中查询语句的执行方法必须采用Statement类实现

考题 程序员将可能发生异常的代码放在()块中,后面紧跟着一个或多个()块。A、catch、tryB、try、catchC、try、exceptionD、exception、try

考题 下列()语句是连接数据库时使用的语句。A、StatementSQL语句变量=连接变量.createStatement()B、Connection连接变量=DriverManager.getConnection(数据库URL,用户帐号,用户密码)C、Class.forName(JDBC驱动程序名)D、连接变量.close()

考题 要使用java程序访问数据库,则必须首先与数据库建立连接,在建立连接前,应加载数据库驱动程序,该语句为()A、Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”)B、DriverManage.getConnection(“”,””,””)C、Result rs= DriverManage.getConnection(“”,””,””).createStatement()D、Statement st= DriverManage.getConnection(“”,””,””).createStaement()

考题 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.

考题 下列()语句是执行SQL语句时使用的语句。A、StatementSQL语句变量=连接变量.createStatement()B、Connection连接变量=DriverManager.getConnection(数据库URL,用户帐号,用户密码)C、Class.forName(JDBC驱动程序名)D、连接变量.close()

考题 try {  int x = 0;  int y = 5 / x;  } catch (Exception e) {  System.out.println(“Exception”);  } catch (ArithmeticException ae) {  System.out.println(“Arithmetic Exception”);  }  System.out.println(“finished”);  What is the result?()  A、 finishedB、 ExceptionC、 Compilation fails.D、 Arithmetic Exception

考题 What is wrong with the following code?()   class MyException extends Exception {}   public class Qb4ab {   public void foo() {  try {  bar();  } finally {  baz();   } catch (MyException e) {}  }   public void bar() throws MyException {   throw new MyException();  }   public void baz() throws RuntimeException {   throw new RuntimeException();   }   }  A、Since the method foo() does not catch the exception generated by the method baz(), it must declare the RuntimeException in its throws clause.B、A try block cannot be followed by both a catch and a finally block.C、An empty catch block is not allowed.D、A catch block cannot follow a finally block.E、A finally block must always follow one or more catch blocks.

考题 class Waiting implements Runnable {  boolean flag = false;  public synchronized void run() {  if (flag) {  flag = false;  System.out.print("1 ");  try { this.wait(); } catch (Exception e) { }  System.out.print("2 ");  }  else {  flag = true;  System.out.print("3 ");  try { Thread.sleep(2000); } catch (Exception e) { }  System.out.print("4 ");  notify();  }  }  public static void main(String [] args) {  Waiting w = new Waiting();  new Thread(w).start();  new Thread(w).start ();  }  }  以下哪两项是正确的?() A、代码输出 1 3 4B、代码输出 3 4 1C、代码输出 1 2 3 4D、代码不会完成

考题 现有:  void topGo()  {      try  {  middleGo();  }  catch  (Exception e)  {      System.out.print("catch");      }      }  void middleGo()  throws Exception  {     go();  system.out.print("late middle");     }  void go()  throws ExceptiOn  {     throw new Exception();     } 如果调用 topGo () ,则结果为:() A、 late middleB、 catchC、 late middle catchD、 catch Iate middle

考题 现有:  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

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

考题 单选题现有:  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 Waiting implements Runnable  {       boolean flag=false;  public  synchronized void run()  {       if  (flag)  {       flag=false;  System.out.print ("1");  try  {  this.wait();  )  catch  (Exception e)  {  }       System.out.print ("2");       }  else  {       flag=true;  System.out.print ("3");  try{Thread.sleep (2000); } catch(Exception e)  {}      System.out.print ("4");       notify();       }       }  public static void main (String  []  args)  {       Waiting w=new Waiting();       new Thread (w) .start();       new Thread (w) .start();       }       }  以下哪两项是正确的?()A代码输出l 3 4B代码输出3 4 1C代码输出l 2 3 4D代码输出1 3 4 2E代码运行完毕F代码不会完成

考题 多选题class Waiting implements Runnable {  boolean flag = false;  public synchronized void run() {  if (flag) {  flag = false;  System.out.print("1 ");  try { this.wait(); } catch (Exception e) { }  System.out.print("2 ");  }  else {  flag = true;  System.out.print("3 ");  try { Thread.sleep(2000); } catch (Exception e) { }  System.out.print("4 ");  notify();  }  }  public static void main(String [] args) {  Waiting w = new Waiting();  new Thread(w).start();  new Thread(w).start ();  }  }  以下哪两项是正确的?()A代码输出 1 3 4B代码输出 3 4 1C代码输出 1 2 3 4D代码不会完成

考题 单选题try {  int x = 0;  int y = 5 / x;  } catch (Exception e) {  System.out.println(“Exception”);  } catch (ArithmeticException ae) {  System.out.println(“Arithmetic Exception”);  }  System.out.println(“finished”);  What is the result?()A  finishedB  ExceptionC  Compilation fails.D  Arithmetic Exception

考题 单选题关于JDBC访问数据库的说法错误的是:()A  建立数据库连接时,必须加载驱动程序,可采用Class.forName()实现B  用于建立与某个数据源的连接可采用DriverManager类的getConnection方法C  建立数据库连接时,必须要进行异常处理D  JDBC中查询语句的执行方法必须采用Statement类实现

考题 单选题现有:  void topGo()  {      try  {  middleGo();  }  catch  (Exception e)  {      System.out.print("catch");      }      }  void middleGo()  throws Exception  {     go();  system.out.print("late middle");     }  void go()  throws ExceptiOn  {     throw new Exception();     } 如果调用 topGo () ,则结果为:()A  late middleB  catchC  late middle catchD  catch Iate middle