JDBC Online Quiz


Advertisements

Following quiz provides Multiple Choice Questions (MCQs) related to JDBC Framework. You will have to read all the given answers and click over the correct answer. If you are not sure about the answer then you can check the answer using Show Answer button. You can use Next Quiz button to check new set of questions in the quiz.

Questions and Answers

Answer : B

Explanation

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

Q 2 - 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 3 - Which of the following type of JDBC driver should be used when you are accessing one type of database, such as Oracle, Sybase, or IBM?

A - Type 1

B - Type 2

C - Type 3

D - Type 4

Answer : D

Explanation

If you are accessing one type of database, such as Oracle, Sybase, or IBM, the preferred driver type is 4.

Q 4 - Which of the following is not a valid type of statement in JDBC?

A - Statement

B - PreparedStatement

C - CallableStatement

D - QueryStatement

Answer : D

Explanation

QueryStatement is not a valid type of statement in JDBC.

Answer : C

Explanation

A savepoint marks a point that the current transaction can roll back to. Instead of rolling all of its changes back, it can choose to roll back only some of them.

Q 7 - Which of the following required to be closed to close database operations?

A - ResultSet

B - Statement

C - Connection

D - All of the above.

Answer : D

Explanation

You need to close the resultset, the statement and the connection. If the connection has come from a pool, closing it actually sends it back to the pool for reuse. We can do this in the finally{} block, such that if an exception is thrown, you still get the chance to close this.

Answer : A

Explanation

First step is to import packages containing the JDBC classes needed for database programming.

Answer : D

Explanation

All of the above methods can be used to create a connection object.

Q 10 - Which of the following is a Metadata interfaces of JDBC?

A - DatabaseMetaData

B - ResultSetMetaData

C - Both of the above.

D - None of the above.

Answer : C

Explanation

JDBC API has two Metadata interfaces : DatabaseMetaData & ResultSetMetaData.

jdbc_questions_answers.htm
Advertisements