Top MCQs on JDBC (Advanced Java)

41.) What is the purpose of the JDBC BatchUpdateException class?

A) To handle exceptions when executing SQL queries
B) To manage database transactions
C) To provide information about batch update failures
D) To retrieve metadata about the database

Answer: Option C

Explanation: The JDBC BatchUpdateException class is used to provide information about batch update failures, such as the number of rows affected and the specific SQL statements that failed.

42.) Which JDBC interface is used to work with large binary or character data, such as images or text documents?

A) Blob
B) Clob
C) A and B both
D) NClob

Answer: Option C

Explanation: The JDBC interface used to work with large binary or character data, such as images or text documents, is the java.sql.Blob (Binary Large Object) and java.sql.Clob (Character Large Object) interfaces. Blob is used for binary data, like images, while Clob is used for character data, like text documents.

43.) In JDBC, what is the purpose of a CallableStatement?

A) To execute complex SQL queries
B) To call stored procedures in the database
C) To handle SQL exceptions
D) To create database triggers

Answer: Option B

Explanation: A CallableStatement in JDBC is used to call stored procedures in the database, making it suitable for executing complex database logic.

44.) Which method allows you to retrieve additional information about database connections in JDBC?

A) getDatabaseInfo()
B) getConnectionInfo()
C) getMetaData()
D) getDatabaseDetails()

Answer: Option C

Explanation: The getMetaData() method in JDBC allows you to retrieve metadata about database connections, tables, columns, and more.

45.) Which SQL join type returns all rows from both tables, filling in missing values with NULL?

A) INNER JOIN
B) LEFT JOIN
C) RIGHT JOIN
D) FULL JOIN

Answer: Option D

Explanation: A FULL JOIN in SQL returns all rows from both tables, filling in missing values with NULL for non-matching rows.

46.) What is the purpose of the JDBC “Savepoint” interface?

A) To save the entire database state
B) To set a specific point within a transaction to which you can later roll back
C) To create database backups
D) To prevent SQL injection attacks

Answer: Option B

Explanation: The JDBC “Savepoint” interface allows you to set a specific point within a transaction to which you can later roll back, providing finer-grained control over transaction management.

47.) In JDBC, what is the significance of the ‘isClosed()’ method for a Connection object?

A) It checks if the database is closed.
B) It checks if the JDBC driver is closed.
C) It checks if the connection to the database is closed.
D) It checks if the connection pool is closed.

Answer: Option C

Explanation: The ‘isClosed()’ method in JDBC checks if the connection to the database is closed, allowing you to determine the status of the connection.

48.) Which JDBC feature allows you to specify the fetch size for a result set?

A) Connection pooling
B) Batch processing
C) ResultSet pagination
D) Statement caching

Answer: Option C

Explanation: ResultSet pagination in JDBC allows you to specify the fetch size for a result set, controlling how many rows are fetched from the database at a time.

49.) In JDBC, what is the significance of the RowSet interface?

A) It represents a single row from a result set.
B) It is used to retrieve metadata about database tables.
C) It provides a scrollable and updatable result set.
D) It handles exceptions during SQL query execution.

Answer: Option C

Explanation: The RowSet interface in JDBC provides a scrollable and updatable result set, allowing you to navigate and modify data efficiently.

50.) In JDBC, what is the primary purpose of the DriverManager class?

A) To manage database connections and connection pooling
B) To provide access to the JDBC API documentation
C) To execute SQL queries asynchronously
D) To control database server configurations

Answer: Option A

Explanation: The DriverManager class in JDBC is primarily used to manage database connections and connection pooling, allowing applications to connect to databases.

Leave a Reply

Your email address will not be published. Required fields are marked *