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

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.

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

Answer : B

Explanation

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

Q 4 - Which of the following represents a regular SQL statement in JDBC?

A - Statement

B - PreparedStatement

C - CallableStatement

D - None of the above.

Answer : A

Explanation

Statement represents a regular SQL statement in JDBC.

Answer : C

Explanation

Class.forName(): This method dynamically loads the driver's class file into memory, which automatically registers it. This method is preferable because it allows you to make the driver registration configurable and portable.

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

Statement is used for general-purpose access to your database. Useful when you are using static SQL statements at runtime. The Statement interface cannot accept parameters.

Answer : B

Explanation

Every vendor of Database provides implementation of ResultSet & other interfaces, through the Driver.

Q 10 - Prepared statements are more secure because they use bind variables, which can prevent SQL injection attack.

A - true

B - false

Answer : A

Explanation

Prepared statements are more secure because they use bind variables, which can prevent SQL injection attack.


jdbc_questions_answers.htm

Advertisements