0% found this document useful (0 votes)
17 views5 pages

Week 11assignment

Uploaded by

dharanip1274
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views5 pages

Week 11assignment

Uploaded by

dharanip1274
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

NPTEL Online Certification Courses

Indian Institute of Technology Kharagpur

OBJECT ORIENTED PROGRAMMING WITH JAVA


Assignment11
TYPE OF QUESTION: MCQ
Number of questions: 10 Total mark: 10× 1 = 10
______________________________________________________________________________

QUESTION 1:
Which of the following statements is true regarding the executeQuery( ) method of the
java.sql.Statement interface in Java Database Connectivity (JDBC)?

a. The executeQuery( ) method is used to execute a DELETE statement.


b. The executeQuery( ) method is used to execute a SELECT statement.
c. The executeQuery( ) method is used to execute an INSERT statement.
d. The executeQuery( ) method is used to execute an UPDATE statement.

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:

DriverManager is responsible for managing a connection to the database.


________________________________________________________________
NPTEL Online Certification Courses
Indian Institute of Technology Kharagpur

QUESTION 3:
What is the primary purpose of a PreparedStatement in JDBC?

a. To execute stored procedures.


b. To execute SQL queries with parameters.
c. To execute batch updates.
d. To retrieve metadata about the database.

Correct Answer: b

Detailed Solution:

The PreparedStatement interface is used to execute parameterized SQL statements in JDBC.

_______________________________________________________________

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:

SQLException is thrown when there is a failure in JDBC database connectivity.


____________________________________________________________________________

QUESTION 5:
What is a "JDBC driver" in the context of database connectivity?

a. A database management system.


b. A Java class for executing SQL queries.
c. A software component that provides a bridge between Java applications and a specific
database.
d. A tool for generating SQL statements.

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:

The next() method moves the cursor to the next row.


_________________________________________________________________

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

JDBC: Type 3 - Network Protocol


The network protocol driver uses middleware (application server) that converts JDBC calls
directly or indirectly into the vendor-specific database protocol. It is fully written in java.
_____________________________________________________________________________

You might also like