- JDBC Tutorial
- JDBC - Home
- JDBC - Introduction
- JDBC - SQL Syntax
- JDBC - Environment
- JDBC - Sample Code
- JDBC - Driver Types
- JDBC - Connections
- JDBC - Statements
- JDBC - Result Sets
- JDBC - Data Types
- JDBC - Transactions
- JDBC - Exceptions
- JDBC - Batch Processing
- JDBC - Stored Procedure
- JDBC - Streaming Data
- JDBC Examples
- JDBC - Create Database
- JDBC - Select Database
- JDBC - Drop Database
- JDBC - Create Tables
- JDBC - Drop Tables
- JDBC - Insert Records
- JDBC - Select Records
- JDBC - Update Records
- JDBC - Delete Records
- JDBC - WHERE Clause
- JDBC - Like Clause
- JDBC - Sorting Data
- JDBC Useful Resources
- JDBC - Questions and Answers
- JDBC - Quick Guide
- JDBC - Useful Resources
- JDBC - Discussion
- Useful - Java Tutorials
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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 Statement class of JDBC?
Answer : C
Explanation
Statement encapsulates an SQL statement which is passed to the database to be parsed, compiled, planned and executed.
Q 2 - In which of the following type of ResultSet, the cursor can only move forward in the result set?
A - ResultSet.TYPE_FORWARD_ONLY
B - ResultSet.TYPE_SCROLL_INSENSITIVE
Answer : A
Explanation
ResultSet.TYPE_FORWARD_ONLY: The cursor can only move forward in the result set.
Q 3 - Which of the following type of JDBC driver, uses database native protocol?
A - JDBC-ODBC Bridge plus ODBC driver
B - Native-API, partly Java driver
Answer : D
Explanation
Native-protocol, pure Java driver, uses database native protocol.
Q 4 - Which of the following is not a valid type of statement in JDBC?
Answer : D
Explanation
QueryStatement is not a valid type of statement in JDBC.
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 - How does JDBC handle the data types of Java and database?
Answer : C
Explanation
The JDBC driver converts the Java data type to the appropriate JDBC type before sending it to the database. It uses a default mapping for most data types. For example, a Java int is converted to an SQL INTEGER.
Q 7 - Which of the following is correct about connection pooling?
B - components like Apache Commons DBCP Component can be used to configure connection pooling.
Answer : C
Explanation
If you use an application server like WebLogic, WebSphere, jBoss, Tomcat. , then your application server provides the facilities to configure for connection pooling. If you are not using an application server then components like Apache Commons DBCP Component can be used.
Q 8 - Which of the following is correct about setFetchSize(int)?
B - setFetchSize(int) affects how the database returns the ResultSet data.
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 is true about 'dirty read'?
Answer : C
Explanation
In typical database transactions, say one transaction reads and changes the value while the second transaction reads the value before committing or rolling back by the first transaction. This reading process is called as 'dirty read'. Because there is always a chance that the first transaction might rollback the change which causes the second transaction reads an invalid value.
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.