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 : C

Explanation

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

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.

Answer : A

Explanation

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

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

PreparedStatement allows mapping different requests with same prepared statement but different arguments to execute the same execution plan. Prepared statements are more secure because they use bind variables, which can prevent SQL injection attack.

Answer : D

Explanation

A transaction is a logical unit of work. To complete a logical unit of work, several actions may need to be taken against a database. Transactions are used to provide data integrity, correct application semantics, and a consistent view of data during concurrent access.

Q 7 - Out of byte[] or a java.sql.Blob, which has best performance when used to manipulate data from database?

A - byte[]

B - java.sql.Blob

Answer : B

Explanation

java.sql.Blob has better performance as it does not extract any data from the database until you explicitly ask it to.

Answer : C

Explanation

setMaxRows(int) method of the ResultSet specifies how many rows a ResultSet can contain at a time. setMaxRows(int) affects the client side JDBC object.

Answer : D

Explanation

Clean up the environment by closing all database resources relying on the JVM's garbage collection.

Q 10 - You can open only one Statement object per connection when you are using the JDBC-ODBC Bridge.

A - true

B - false

Answer : A

Explanation

You can open only one Statement object per connection when you are using the JDBC-ODBC Bridge.


jdbc_questions_answers.htm

Advertisements