Back to programming Quizzes

JDBC Quiz ( Intermediate )

This intermediate JDBC quiz is designed for developers who know basic database connectivity and want to deepen their understanding of real-world JDBC usage. It focuses on prepared statements, transactions, batch processing, ResultSet types, metadata, connection handling, and commonly asked JDBC interview scenarios.

15
Questions
~10
Minutes
10
Min Limit

Try a few sample questions

The question bank contains 48 questions. Your scored round uses up to 15 different questions. These samples are excluded from your round; try each one before opening its answer and explanation.

1. Why is PreparedStatement preferred over Statement in real-world applications?

  1. It uses less memory
  2. It prevents SQL injection and improves performance
  3. It supports only SELECT queries
  4. It does not require connection
Reveal sample answer and explanation

Answer: It prevents SQL injection and improves performance

PreparedStatement improves security and performance by precompiling SQL.

2. What happens when auto-commit mode is disabled?

  1. Queries fail
  2. Each statement is committed automatically
  3. Transactions must be committed manually
  4. Rollback is disabled
Reveal sample answer and explanation

Answer: Transactions must be committed manually

Manual commit is required when auto-commit is false.

3. Which JDBC method disables auto-commit mode?

  1. disableAutoCommit()
  2. setAutoCommit(false)
  3. commit(false)
  4. autoCommitOff()
Reveal sample answer and explanation

Answer: setAutoCommit(false)

setAutoCommit(false) disables auto-commit.