JDBC Online Quiz
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.
Q 1 - Which of the following is correct about driver interface of JDBC?
A - JDBC driver is an interface enabling a Java application to interact with a database.
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.
Q 2 - Which of the following encapsulates an SQL statement which is passed to the database to be parsed, compiled, planned and executed?
Answer : D
Explanation
Statement encapsulates an SQL statement which is passed to the database to be parsed, compiled, planned and executed.
Q 3 - Which of the following type of JDBC driver, is also called Type 2 JDBC driver?
A - JDBC-ODBC Bridge plus ODBC driver
B - Native-API, partly Java driver
Answer : B
Explanation
Native-API, partly Java driver, is also called Type2 JDBC driver.
Q 4 - Which of the following type of JDBC driver is the fastest one?
Answer : D
Explanation
JDBC Net pure Java driver(Type 4) is the fastest driver because it converts the JDBC calls into vendor specific protocol calls and it directly interacts with the database.
Q 5 - Which of the following is correct about PreparedStatement?
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.
Q 6 - Which of the following is correct about SQL Warning?
B - Connection, Statement and ResultSet has a getWarnings method.
Answer : C
Explanation
A warning can be reported on a Connection object, a Statement object (including PreparedStatement and CallableStatement objects), or a ResultSet object. Each of these classes has a getWarnings method.
Q 7 - Which of the following is true about attribute Concurrency in ResultSet?
A - The ResultSet concurrency determines whether the ResultSet can be updated.
B - The ResultSet concurrency determines whether the ResultSet can be read only.
Answer : C
Explanation
The ResultSet concurrency determines whether the ResultSet can be updated, or only read.
Q 8 - Which of the following is correct about setMaxRows(int)?
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.
Q 9 - Which of the following method can be used to create a connection object?
A - getConnection(String url, String user, String password)
Answer : D
Explanation
All of the above methods can be used to create a connection object.
Q 10 - New drivers can be plugged-in to the JDBC API without changing the client code.
Answer : A
Explanation
New drivers can be plugged-in to the JDBC API without changing the client code.