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

Q 1 - 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 2 - 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.

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 the standard isolation levels defined by JDBC?

A - TRANSACTION_NONE

B - TRANSACTION_REPEATABLE_READ

C - TRANSACTION_SERIALIZABLE

D - TRANSACTION_REPEATABLE_WRITE

Answer : C

Explanation

TRANSACTION_REPEATABLE_WRITE is not a standard isolation levels defined by JDBC.

Answer : D

Explanation

Prepared statements offer better performance, as they are pre-compiled. Prepared statements reuse the same execution plan for different arguments rather than creating a new execution plan every time. Prepared statements use bind arguments, which are sent to the database engine.

Q 6 - Which of the following is used generally used for altering the databases?

A - boolean execute()

B - ResultSet executeQuery()

C - int executeUpdate()

D - None of the above.

Answer : C

Explanation

int executeUpdate(): This is generally used for altering the databases. Generally DROP TABLE or DATABASE, INSERT into TABLE, UPDATE TABLE, DELETE from TABLE statements will be used in this. The output will be in the form of int which denotes the number of rows affected by the query.

Answer : C

Explanation

Database vendor's help multiple clients to share a cached set of connection objects that provides access to a database. Clients need not create a new connection everytime to interact with the database.

Answer : D

Explanation

A disconnected RowSet object is ad-hoc in nature. Whenever it requires retrieving data from the database, it establishes the connection and closes it upon finishing the required task. The data that is modified during disconnected state is updated after the connection is re-established.

Q 9 - Which isolation level prevents dirty read in JDBC, connection class?

A - TRANSACTION_READ_COMMITTED

B - TRANSACTION_NONE

C - TRANSACTION_READ_UNCOMMITTED

D - TRANSACTION_REPEATABLE_READ

Answer : A

Explanation

TRANSACTION_READ_COMMITTED prevents dirty read in JDBC, connection class.

Answer : D

Explanation

Class.forName("MyClass") first loads the class MyClass then executes any static block code of MyClass and returns an instance of MyClass.

jdbc_questions_answers.htm
Advertisements