Halaman

Tuesday, July 21, 2020

Section 6 Quiz Java Programming 2019 Learner - English

Section 6
(Answer all questions in this section)

How many categories of JDBC drivers are there?


1


2


3


4 (*)





Which of the following classes or interfaces are included in the database vendor driver library? (Choose two)

(Choose all correct answers)


Statement interface implementation (*)


Java.sql.Connection


Javax.sql.DataSource


Javax.sql.DataSource implementation (*)


Java.sql.DriverManager implementation



The java.sql.DriverManager class will typically be registered with a naming service based on the Java Naming Directory (JNDI) API.


True


False (*)



What type of JDBC driver will convert the database invocation directly into network protocol?


Type 1 driver


Type 2 driver


Type 3 driver


Type 4 driver (*)



Which of the following is a valid JDBC URL?


oracle:thin:localhost@dfot/dfot:1521/xepdb1


jdbc::oracle-thin:dfot/dfot@oracle:1521/xepdb1


jdbc:oracle:thin:dfot/dfot@localhost:1521/xepdb1 (*)


oracle:thin:jdbc:dfot/dfot@localhost:1521/xepdb1


To execute a stored SQL procedure, which JDBC interface should be used?


Statement Interface


PreparedStatement Interface


PrePreparedStatement Interface


CallableStatement Interface (*)


Which of the following is NOT a JDBC interface used to execute SLQ statements?


Statement Interface


PreparedStatement Interface


PrePreparedStatement Interface (*)


CallableStatement Interface



Which of the following is the correct statement be inserted at //INSERT CODE location that calls the database-stored procedure sayHello?

class Test{
  public static void main(String[] args) {
   try {
    Connection conn = getConnection();
    //INSERT CODE
    cstat.setString(1, "Hello");
    cstat.registerOutParameter(2, Types.NUMERIC);
    cstat.setInt(2, 10);
   }
   catch(SQLException e){}
  }
}


CallableStatement cstat = con.prepareCall("{sayHello(?, ?)}");


CallableStatement cstat = con.prepareCall("{call procedure_sayHello (?, ?)}");


CallableStatement cstat = con.prepareCall("{call sayHello}");


CallableStatement cstat = con.prepareCall("sayHello(?, ?)");


CallableStatement cstat = con.prepareCall("{call sayHello(?, ?)}"); (*)



Which JDBC interface can be used to access information such as database URL, username and table names?


Statement Interface


PreparedStatement Interface


DatabaseMetaData Interface (*)


CallableStatement Interface



Which the following statements is NOT TRUE about DataSource?


DataSource can be implemented as a pool of connections.


DataSource can participate in the Distributed transaction.


DataSource can manage a set of JDBC Drivers registered in the system. (*)


DataSource will typically be registered with a naming service.


Which type of Statement can execute parameterized queries?


ParameterizedStatement


CallableStatement and ParameterizedStatement


PreparedStatement (*)


All of the above



Which symbol is used as a placeholder to pass parameters to a PreparedStatement or CallableStatement?


!


? (*)


@


#



From JDBC, how would you execute DML statements (i.e. insert, delete, update) in the database?


By making use of the execute(...) statement from DataStatement Object


By invoking the executeDelete(...), executeUpdate(...) methods of the DataStatement


By invoking the execute(...) or executeUpdate(...) method of a JDBC Statement object or sub-interface object (*)


By invoking the DeleteStatement or UpdateStatement JDBC object



Suppose that you have a table EMPLOYEES with three rows. The first_name in those rows are A, B, and C. What does the following output?

String sql = "select first_name from Employees order by first_name desc";
Statement stmt=conn.createStatement = (ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
ResultSet rset= stmt.executeQuery(sql);
rset.absolute(1);
rset.next();
System.out.println(rset.getString(1));


A


B (*)


C


The code does not compile.


A SQLException is thrown.



Which of the following methods will move the cursor, returning a Boolean value from the ResultSet Object?

(Choose all correct answers)


beforeFirst() (*)


absolute()


afterFirst()


afterLast()


beforeLast()


previous() (*)

No comments:

Post a Comment

Final Exam Java Programming 2019 Learner - English

Final Exam