You are on page 1of 7

HCM21_CPL_JAVA_06    Tests & Quizzes

Tests & Quizzes

05_BTJB_Quiz4_Database Programming with JDBC


Return to Assessment List

Part 1 of 1 - 40.0/ 100.0 Points

Question 1 of 20
Which of the following methods are needed for loading a database driver in JDBC 5.0/ 5.0 Points

A. registerDriver() method

B. getConnection()

C. Class.forName()

D. Both A and B

Question 2 of 20
To uniquely identify each row in a table, a relational database uses a ? 0.0/ 5.0 Points

A. record

B. relational database management system

C. primary key

D. foreign key

Question 3 of 20
What a correct ordering of steps should be to using a updatable recordset to insert new 5.0/ 5.0 Points
customers into the Customer table.

A. Prompt user for customer information


B. Call set methods for each column using customer information
C. Execute statement S3 selecting the Customer table, return result set R1
D. Close S3
E. Ask if more customers to add, if so go back to ""Prompt user""
F. Close connection
G. Open connection to database
H. Close R1
I. Create statement S3 using SCROLLABLE and UPDATABLE flags
J. Go to insert row of R1
K. Call R1.insertRow

A. G_I_C_J_A_B_K_E_H_D_F

B. I_G_C_J_A_B_E_K_H_D_F

C. I_G_C_J_A_B_K_E_H_D_F

D. G_I_C_J_A_B_K_E_D_H_F

Question 4 of 20
Which of following interface isn’t used by JDBC 0.0/ 5.0 Points

A. java.sql.Driver

B. java.sql.Connection

C. java.sql.DriverManager

D. java.sql.DatabaseMetaData

Question 5 of 20
A __________ result set has a cursor that moves both forward and backward and can be 0.0/ 5.0 Points
moved to a particular row

A. nonscrollable

B. Unscrollable

C. scrollable

Question 6 of 20
Package _______ contains classes and interfaces for manipulating relational databases in 5.0/ 5.0 Points
Java. ?

A. java.sql

B. sql.java

C. java.connection

D. sql.rar
Question 7 of 20
Which driver is efficient and always preferable for using JDBC applications 0.0/ 5.0 Points

A. Type – 1

B. Type – 4

C. Type – 2

D. Type – 3

Question 8 of 20
What statements are correct about JDBC transactions (2 correct answers)? 0.0/ 5.0 Points

A. A transaction is a set of successfully executed statements in the database

B. A transaction is finished when close() is called on the Connection object

C. A transaction is finished when commit() or rollback() is called on the Transaction object

D. A transaction is finished when commit() or rollback() is called on the Connection object,

Question 9 of 20
Which method is used to perform DML statements in JDBC 5.0/ 5.0 Points

A. executeUpdate()

B. executeQuery()

C. execute()

D. executeResult()

Question 10 of 20
Suppose that a database server does not support a pure JDBC driver, but it does support an 5.0/ 5.0 Points
ODBC driver. How can you access the database server using JDBC?

A. Use the JDBC-ODBC bridge driver.

B. Use JNDI.

C. Use SQL.

D. Use Java RMI.


Question 11 of 20
How can you start a database transaction in the database 5.0/ 5.0 Points

A.
By setting the autoCommit property of the Connection to false, and execute a statement in the database

B. By asking a Transaction object to your Connection, and calling the method begin() on it

C.
By asking a Transaction object to your Connection, and setting the autoCommit property of the
Transaction to false

D. By calling the method beginTransaction() on the Connection object

Question 12 of 20
Which of the following methods finds the maximum number of connections that a specific driver 0.0/ 5.0 Points
can obtain

A. ResultSetMetaData.getMaxConnections

B. DatabaseMetaData.getMaxConnections

C. Connection.getMaxConnections

D. Database.getMaxConnections

Question 13 of 20
Which of the following describes a JDBC type 4 driver? 0.0/ 5.0 Points

A. Native-API partly Java driver

B. JDBC-ODBC bridge plus ODBC driver

C. JDBC-Net pure Java driver

D. Native-protocol pure Java driver

Question 14 of 20
How do you know in your Java program that a SQL warning is generated as a result of 0.0/ 5.0 Points
executing a SQL statement in the database

A. You must query the ResultSet object about possible warnings generated by the database
B.
You must catch the unchecked SQLWarningException which is thrown by the method which executes the
statement

C.
You must catch the checked SQLException which is thrown by the method which executes the statement

D. You must invoke the getWarnings() method on the Statement object (or a sub interface thereof)

Question 15 of 20
The result set retrieved by the following SELECT statement contains records that have 5.0/ 5.0 Points

SELECT Balance, Num


FROM Accounts
WHERE Balance < 0
?

A. two fields from the Accounts table where Balance is less than 0

B. two fields from the Balance table where Account Num is less than 0

C. one field from the Balance table where Account Num is less than 0

D. all fields from the Accounts table where Balance is less than 0

Question 16 of 20
Which of the following is false as far as type 4 driver is concern 0.0/ 5.0 Points

A. Type 4 drivers uses Socket class to connect to the database

B. Type 4 drivers are 100% Java compatible

C. Type 4 driver is “native protocol, pure java” driver

D. Type 4 drivers cannot be used with Netscape

Question 17 of 20
A transaction is a set of one or more statements that is executed as a unit, it means 0.0/ 5.0 Points
______________
A.
You must sure that all statements are OK before executing it, otherwise, you can not execute this
transaction.

B. All of the statements are executed or none of the statements is executed

C. All of the statements are executed or some of the statements are executed, it's OK to JDBC.

D.
No problem, even in case some statements are committed and the others are rolled back, it's OK to
JDBC.

Question 18 of 20
A __________ object contains information about a result set like the numbers and names of the 0.0/ 5.0 Points
columns in the result set. ?

A. OR mapping (object to relational)

B. ResultSetMetaData

C. connection pooling

D. prepared statements

Question 19 of 20
The _______ interfaces is used to encapsulate SQL queries used for retrieving data from the 5.0/ 5.0 Points
database ?

A. Statement

B. Callable

C. Prepared

D. Parameter

Question 20 of 20
If one intends to work with a ResultSet, which of these PreparedStatement methods will not 0.0/ 5.0 Points
work?

A. executeQuery()

B. execute()
C. executeUpdate()

Gateway
Accessibility Information
The Sakai Project

Powered by Sakai
Copyright 2017 FPT-Software

You might also like