Week 11Assignment.docx
Week 11Assignment.docx
QUESTION 1:
MySQL is a ______.
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
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?
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.
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.
_____________________________________________________________________________