Week 11assignment
Week 11assignment
QUESTION 1:
Which of the following statements is true regarding the executeQuery( ) method of the
java.sql.Statement interface in Java Database Connectivity (JDBC)?
Correct Answer: b
Detailed Solution:
The executeQuery( ) method is used to execute a SELECT statement.
_________________________________________________________________________
QUESTION 2:
In JDBC, which component is responsible for managing a connection to the database?
a. DriverManager
b. Connection
c. Statement
d. ResultSet
Correct Answer: a
Detailed Solution:
QUESTION 3:
What is the primary purpose of a PreparedStatement in JDBC?
Correct Answer: b
Detailed Solution:
_______________________________________________________________
QUESTION 4:
Which exception is commonly thrown when there is a failure in JDBC database
connectivity?
a. FileNotFoundException
b. NullPointerException
c. SQLException
d. ClassNotFoundException
Correct Answer: c
Detailed Solution:
QUESTION 5:
What is a "JDBC driver" in the context of database connectivity?
Correct Answer: c
NPTEL Online Certification Courses
Indian Institute of Technology Kharagpur
Detailed Solution:
JDBC driver: A software component that provides a bridge between Java applications and a
specific database.
_____________________________________________________________________________
QUESTION 6:
Which package in Java contains the classes and interfaces for JDBC?
a. java.sql
b. java.io
c. java.db
d. java.net
Correct Answer: a
Detailed Solution:
java.sql package in Java contains the classes and interfaces for JDBC.
______________________________________________________________________________
QUESTION 7:
Which method is used to execute a batch of SQL statements in JDBC?
a. executeBatch( )
b. executeUpdateBatch( )
c. executeBatchUpdate( )
d. executeUpdate( )
Correct Answer: a
Detailed Solution:
Batch updates in JDBC allow multiple SQL statements to be executed in a single transaction.
They can be used for any type of SQL statement, including INSERT, UPDATE, and DELETE.
Batch updates are executed when the batch is executed, either explicitly using the executeBatch(
) method or implicitly when the batch size limit is reached. Batch updates can be rolled back
using the rollback( ) method.
NPTEL Online Certification Courses
Indian Institute of Technology Kharagpur
QUESTION 8:
Which method is used to move the cursor to the next row in a ResultSet?
a. nextRow( )
b. next( )
c. moveNext( )
d. moveRow( )
Correct Answer: b
Detailed Solution:
QUESTION 9:
Which type of JDBC driver is also known as the "Thin driver"?
a. Type 1 driver
b. Type 2 driver
c. Type 3 driver
d. Type 4 driver
Correct Answer: d
Detailed Solution:
JDBC: Type 4 - Thin Driver
The thin driver converts JDBC calls directly into the vendor-specific database protocol. That is
why it is known as thin driver. It is fully written in Java language.
_____________________________________________________________________________
QUESTION 10:
Which type of JDBC driver is a pure Java driver that communicates with the database
using a middleware server?
a. Type 1 driver
b. Type 2 driver
c. Type 3 driver
d. Type 4 driver
Correct Answer: c
Detailed Solution:
NPTEL Online Certification Courses
Indian Institute of Technology Kharagpur