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

Week 11Assignment.docx

Uploaded by

4113 PAVITHRA K
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)
6 views5 pages

Week 11Assignment.docx

Uploaded by

4113 PAVITHRA K
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:
MySQL is a ______.

a. Java Database Connectivity Driver


b. Relational Database Management System
c. Java Runtime Environment
d. Java Development Kit

Correct Answer: b

Detailed Solution:
MySQL is an Oracle-backed open source relational database management system (RDBMS)
based on Structured Query Language (SQL).
_________________________________________________________________________

QUESTION 2:
The …………………… object allows you to execute parametrized queries.

a. ResultSet
b. PreparedStatement
c. ParameterizedStatement
d. Condition

Correct Answer: b

Detailed Solution:
NPTEL Online Certification Courses
Indian Institute of Technology Kharagpur

The PreparedStatement interface extends the Statement interface. It represents a precompiled


SQL statement that can be executed multiple times. It accepts parameterized SQL quires.
________________________________________________________________

QUESTION 3:
Which of the following best describes about JDBC?

a. JDBC works like a bridge connecting a Java application to a RDBMS, execute SQL
commands and return results to the application.
b. JDBC is a software component, which is both network and database independent.
c. JDBC should be installed in the same machine from where the Java application will run.
d. JDBC should be installed in the same server that of the database.

Correct Answer: a

Detailed Solution:
The JDBC driver for different databases is different. But, as an end-user, we don’t have to bother
about their implementation. The networking is also not an issue for the users. Further, JDBC can
be installed anywhere in between the client and server.

_________________________________________________________________________

QUESTION 4:
Which of the following is not a JDBC drivers?

a. Native – API driver


b. Thin driver
c. Network protocol driver
d. Local Protocol driver

Correct Answer: d

Detailed Solution:

There are 4 types of JDBC drivers : JDBC-ODBC bridge driver, network protocol driver,
native-API driver and thin driver.
NPTEL Online Certification Courses
Indian Institute of Technology Kharagpur

____________________________________________________________________________

QUESTION 5:
The package, which is required to be imported for the JDBC programming?

a. java.net
b. java.sql
c. java.lang
d. java.io

Correct Answer: b

Detailed Solution:
java.sql is required to be imported for the JDBC programming.

______________________________________________________________________________

QUESTION 6:
How do you know in your Java program that a SQL warning is generated as a result of
executing a SQL statement in the database?
a. You must catch the checked SQLException which is thrown by the method which
executes the statement.
b. You must catch the unchecked SQLWarningException which is thrown by the method
which executes the statement.
c. You must invoke the getWarnings() method on the Statement object (or a sub interface
thereof ).
d. You must query the ResultSet object about possible warnings generated by the database.
Correct Answer: c

Detailed Solution:
The getWarnings() method can return, if the SQL database server returns any error or warning.

______________________________________________________________________________

QUESTION 7:
Which one of the following contains both date and time information?
NPTEL Online Certification Courses
Indian Institute of Technology Kharagpur

a. java.sql.TimeStamp
b. java.sql.Time
c. java.io.Time
d. java.io.TimeStamp

Correct Answer: a

Detailed Solution:
java.sql.Time contains only time. Whereas, java.sql.TimeStamp contains both time and date.

QUESTION 8:
The following is a statement in Java using JDBC.

Connection con = DriverManager.getConnection


("jdbc:mysql://localhost:3306/nptel","joy","java");

Which of the following statement(s) is/are true?

a. 3306 is the default MySQL port.


b. Database name is ‘nptel’
c. The database server is hosted on IP 127.0.0.1
d. Password for user ‘java’ is ‘joy’

Correct Answer: a,b,c

Detailed Solution:
Password for user ‘joy’ is ‘java’.
_________________________________________________________________

QUESTION 9:
Which of the following method is used to perform DML statements in JDBC?
a. executeResult()
b. executeQuery()
NPTEL Online Certification Courses
Indian Institute of Technology Kharagpur

c. executeUpdate()
d. execute()
Correct Answer: c

Detailed Solution:
The executeUpdate() method for DML SQL queries that change data in the database, such as
INSERT, UPDATE, and DELETE which do not return a resultset.
_____________________________________________________________________________

QUESTION 10:
The …………………. method sets the query parameters of the PreparedStatement Object.

a. putString( )
b. insertString( )
c. setString( )
d. setToString( )

Correct Answer: c

Detailed Solution:
The setter methods (setShort, setString, and so on) for setting input parameter values must
specify types that are compatible with the defined SQL type of the input parameter.

_____________________________________________________________________________

You might also like