Java JDBC

Here are 10 essential multiple-choice questions on Java JDBC, covering key concepts.


Last Updated :
Discuss
Comments

Question 1

What is the main purpose of JDBC in Java?

  • Manage user authentication

  • Connect and interact with databases

  • Enhance file operations

  • Optimize memory usage

Question 2

Which JDBC driver type translates JDBC calls into database-specific calls without using native libraries?

  • Type-1


  • Type-2

  • Type-3

  • Type-4

Question 3

Before executing any SQL query, which method must be called to establish a database connection?


  • DriverManager.registerDriver()

  • Connection.prepare()

  • DriverManager.getConnection()

  • DriverManager.createConnection()

Question 4

Which interface represents a SQL database connection in JDBC?


  • ResultSet

  • Statement

  • Connection

  • DriverManager

Question 5

Which JDBC statement is used when you need to execute dynamic SQL with different parameters at runtime?

  • Statement

  • PreparedStatement

  • CallableStatement

  • ResultSet

Question 6

What exception does JDBC primarily throw when something goes wrong?


  • IOException

  • SQLException

  • DatabaseException


  • JDBCException


Question 7

Identify the correct order to perform basic JDBC operations:

  • Connect → Create Statement → Execute Query → Close

  • Create Statement → Connect → Execute Query → Close

  • Execute Query → Connect → Create Statement → Close

  • Connect → Execute Query → Create Statement → Close


Question 8

Given the snippet below, what will it print if the database is connected successfully?

Java
Connection con = DriverManager.getConnection(dbURL, user, pass);
if (con != null) {
    System.out.println("Connection Successful");
}
  • Connection Failed

  • Exception Thrown

  • Connection Successful

  • No Output


Question 9

Which JDBC driver type uses an intermediate server to communicate with the database?


  • Type-1

  • Type-2

  • Type-3

  • Type-4

Question 10

Which of the following is true for CallableStatement?

  • It executes simple SQL queries only

  • It is used to call stored procedures in a database

  • It can only be used for SELECT operations

  • It is used to manage JDBC drivers

There are 10 questions to complete.

Take a part in the ongoing discussion