JDBC - Mock Test


This section presents you various set of Mock Tests related to JDBC Framework. You can download these sample mock tests at your local machine and solve offline at your convenience. Every mock test is supplied with a mock test key to let you verify the final score and grade yourself.

Questions and Answers

JDBC Mock Test I

Answer : A

Explanation

JDBC stands for Java Database Connectivity.

Answer : B

Explanation

JDBC is a standard Java API for database-independent connectivity between the Java programming language and a wide range of databases.

Answer : C

Explanation

General JDBC Architecture consists of two layers: JDBC API (This provides the application-to-JDBC Manager connection) and JDBC Driver API (This supports the JDBC Manager-to-Driver Connection).

Q 4 - Which of the following is not a component/class of JDBC API?

A - DriverManager

B - Driver

C - Connection

D - Transaction

Answer : D

Explanation

Transaction is not a class of JDBC API. JDBC API consists of following interfaces and classes: DriverManager, Driver, Connection, Statement, ResultSet, SQLException.

Q 5 - Which of the following is not a component/class of JDBC API?

A - Statement

B - ResultSet

C - SQLException

D - ConnectionPool

Answer : D

Explanation

ConnectionPool is not a class of JDBC API. JDBC API consists of following interfaces and classes: DriverManager, Driver, Connection, Statement, ResultSet, SQLException.

Answer : C

Explanation

JDBC DriverManager is a class that manages a list of database drivers. It matches connection requests from the java application with the proper database driver using communication subprotocol.

Answer : C

Explanation

JDBC driver is an interface enabling a Java application to interact with a database. To connect with individual databases, JDBC requires drivers for each database. The JDBC driver gives out the connection to the database and implements the protocol for transferring the query and result between client and database.

Answer : C

Explanation

Connection interface consists of methods for contacting a database. The connection object represents communication context.

Answer : C

Explanation

Statement encapsulates an SQL statement which is passed to the database to be parsed, compiled, planned and executed.

Answer : D

Explanation

ResultSet objects hold data retrieved from a database after you execute an SQL query using Statement objects. It acts as an iterator to allow you to move through its data. The java.sql.ResultSet interface represents the result set of a database query.

Q 11 - Which of the following manages a list of database drivers in JDBC?

A - DriverManager

B - JDBC driver

C - Connection

D - Statement

Answer : A

Explanation

DriverManager class manages a list of database drivers in JDBC.

Q 12 - Which of the following gives out the connection to the database and implements the protocol for transferring the query and result between client and database?

A - DriverManager

B - JDBC driver

C - Connection

D - Statement

Answer : B

Explanation

JDBC driver gives out the connection to the database and implements the protocol for transferring the query and result between client and database.

Q 13 - Which of the following consists of methods for contacting a database?

A - DriverManager

B - JDBC driver

C - Connection

D - Statement

Answer : C

Explanation

Connection consists of methods for contacting a database.

Q 14 - Which of the following encapsulates an SQL statement which is passed to the database to be parsed, compiled, planned and executed?

A - DriverManager

B - JDBC driver

C - Connection

D - Statement

Answer : D

Explanation

Statement encapsulates an SQL statement which is passed to the database to be parsed, compiled, planned and executed.

Q 15 - Which of the following holds data retrieved from a database after you execute an SQL query using Statement objects?

A - ResultSet

B - JDBC driver

C - Connection

D - Statement

Answer : A

Explanation

ResultSet holds data retrieved from a database after you execute an SQL query using Statement objects.

Answer : D

Explanation

ResultSet.TYPE_BACKWARD_ONLY is not a valid type of ResultSet.

Q 17 - In which of the following type of ResultSet, the cursor can only move forward in the result set?

A - ResultSet.TYPE_FORWARD_ONLY

B - ResultSet.TYPE_SCROLL_INSENSITIVE

C - ResultSet.TYPE_SCROLL_SENSITIVE

D - None of the above.

Answer : A

Explanation

ResultSet.TYPE_FORWARD_ONLY: The cursor can only move forward in the result set.

Q 18 - In which of the following type of ResultSet, the cursor can scroll forwards and backwards, and the result set is not sensitive to changes made by others to the database that occur after the result set was created.?

A - ResultSet.TYPE_FORWARD_ONLY

B - ResultSet.TYPE_SCROLL_INSENSITIVE

C - ResultSet.TYPE_SCROLL_SENSITIVE

D - None of the above.

Answer : B

Explanation

ResultSet.TYPE_SCROLL_INSENSITIVE: The cursor can scroll forwards and backwards, and the result set is not sensitive to changes made by others to the database that occur after the result set was created.

Q 19 - In which of the following type of ResultSet, the cursor can scroll forwards and backwards, and the result set is sensitive to changes made by others to the database that occur after the result set was created?

A - ResultSet.TYPE_FORWARD_ONLY

B - ResultSet.TYPE_SCROLL_INSENSITIVE

C - ResultSet.TYPE_SCROLL_SENSITIVE

D - None of the above.

Answer : C

Explanation

ResultSet.TYPE_SCROLL_SENSITIVE: The cursor can scroll forwards and backwards, and the result set is sensitive to changes made by others to the database that occur after the result set was created.

Q 20 - Which of the following type of JDBC driver, calls native code of the locally available ODBC driver?

A - JDBC-ODBC Bridge plus ODBC driver

B - Native-API, partly Java driver

C - JDBC-Net, pure Java driver

D - Native-protocol, pure Java driver

Answer : A

Explanation

JDBC-ODBC Bridge plus ODBC driver calls native code of the locally available ODBC driver.

Q 21 - Which of the following type of JDBC driver, calls database vendor native library on a client side. This code then talks to database over network?

A - JDBC-ODBC Bridge plus ODBC driver

B - Native-API, partly Java driver

C - JDBC-Net, pure Java driver

D - Native-protocol, pure Java driver

Answer : B

Explanation

Native-API, partly Java driver calls database vendor native library on a client side. This code then talks to database over network.

Q 22 - Which of the following type of JDBC driver, talks with the server-side middleware that then talks to database?

A - JDBC-ODBC Bridge plus ODBC driver

B - Native-API, partly Java driver

C - JDBC-Net, pure Java driver

D - Native-protocol, pure Java driver

Answer : C

Explanation

JDBC-Net, pure Java driver, partly Java driver talks with the server-side middleware that then talks to database.

Answer : D

Explanation

Native-protocol, pure Java driver, uses database native protocol.

Answer : A

Explanation

JDBC-ODBC Bridge plus ODBC driver, is also called Type 1 JDBC driver.

Answer : B

Explanation

Native-API, partly Java driver, is also called Type2 JDBC driver.

Answer Sheet

Question Number Answer Key
1 A
2 B
3 C
4 D
5 D
6 C
7 C
8 C
9 C
10 D
11 A
12 B
13 C
14 D
15 A
16 D
17 A
18 B
19 C
20 A
21 B
22 C
23 D
24 A
25 B
Advertisements