0% found this document useful (0 votes)
20 views8 pages

JDBC - Chapter 4

The document discusses JDBC and contains multiple choice questions about JDBC concepts and usage. It covers topics like the different types of JDBC drivers, executing queries and stored procedures with JDBC, and using ResultSet objects. The document tests understanding of fundamental JDBC concepts and APIs.

Uploaded by

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

JDBC - Chapter 4

The document discusses JDBC and contains multiple choice questions about JDBC concepts and usage. It covers topics like the different types of JDBC drivers, executing queries and stored procedures with JDBC, and using ResultSet objects. The document tests understanding of fundamental JDBC concepts and APIs.

Uploaded by

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

JDBC

1. The JDBC-ODBC bridge is


[A] Multithreaded
[B] Singlethreaded
[C] Both of the above
[D] none of the above

Answer: A. Multithreaded

2. Which statements about JDBC are true?


[A] JDBC is an API to connect to relational-, object- and XML data sources
[B] JDBC stands for Java DataBase Connectivity
[C] JDBC is an API to access relational databases,
[D] JDBC is an API to bridge the object-relational mismatch between OO programs
and relational databases

Answer: B. JDBC stands for Java Database Connectivity

3. Which packages contain the JDBC classes?


[A] java.jdbc and javax.jdbc
[B] java.jdbc and java.jdbc.sql
[C] java.sql and javax.sql
[D] java.rdb and javax.rdb

Answer: C. java.sql and javax.sql

4. Which type of driver provides JDBC access via one or more ODBC drivers?
[A] Type 1 driver
[B] Type 2 driver
[C] Type 3 driver
[D] Type 4 driver

Answer: A. Type 1 driver

Explanation: none
5. Which type of driver converts JDBC calls into the network protocol used by the
database management system directly?
[A] Type 1 driver
[B] Type 2 driver
[C] Type 3 driver
[D] Type 4 driver

6. JDBC stands for:


[A] Java Database Connectivity
[B] Java Database Components
[C] Java Database Control
[D] None of the above is correct.

Answer: A. Java Database Connectivity

Explanation: none

7. What MySQL property is used to create a surrogate key in MySQL?


[A] UNIQUE
[B] SEQUENCE
[C] AUTO_INCREMENT
[D] None of the above -- Surrogate keys are not implemented in MySQL.

Answer: C. AUTO_INCREMENT

8. ________ is an open source DBMS product that runs on UNIX, Linux and
Windows.
[A] MySQL
[B] JSP/SQL
[C] JDBC/SQL
[D] Sun ACCESS

Answer: A. MySQL
9. Which JDBC driver Type(s) can be used in either applet or servlet code?
[A] Both Type 1 and Type 2
[B] Both Type 1 and Type 3
[C] Both Type 3 and Type 4
[D] Type 4 only

Answer: C. Both Type 3 and Type 4

10. Where is metadata stored in MySQL?


[A] In the MySQL database metadata
[B] n the MySQL database metasql
[C] In the MySQL database mysql
[D] None of the above is correct.

Answer: C. In the MySQL database mysql

11. Which of the following methods are needed for loading a database driver in
JDBC?
[A] registerDriver() method
[B] Class.forName()
[C] Both A and B
[D] getConnection()

Answer: C. Both A and B

12. Which of the following statements is false as far as different type of statements
is concern in JDBC?
[A] Regular Statement
[B] Prepared Statement
[C] Callable Statement
[D] Interim Statement

Answer: D. Interim Statement

13. Which of the following allows non repeatable read in JDBC Connection?
[A] TRANSACTION_READ_UNCOMMITTED
[B] TRANSACTION_READ_COMMITTED
[C] TRANSACTION_SERIALIZABLE
[D] TRANSACTION_REPEATABLE_READ

Answer: D. TRANSACTION_REPEATABLE_READ
14. The JDBC-ODBC Bridge supports multiple concurrent open statements per
connection?
[A] True
[B] False

Answer: A. True

15. Which type of Statement can execute parameterized queries?


[A] PreparedStatement
[B] ParameterizedStatement
[C] ParameterizedStatement and CallableStatement
[D] All kinds of Statements

Answer: A. PreparedStatement

16. Which type of Statement can execute parameterized queries?


[A] PreparedStatement
[B] ParameterizedStatement
[C] ParameterizedStatement and CallableStatement
[D] All kinds of Statements

Answer: A. PreparedStatement

Explanation: PreparedStatement is used to get parametre to make query and to perform


operation into the database.

17. How can you retrieve information from a ResultSet?


[A] By invoking the method get(..., String type) on the ResultSet, where type is the
database type
[B] By invoking the method get(..., Type type) on the ResultSet, where Type is an
object which represents a database type
[C] By invoking the method getValue(...), and cast the result to the desired Java type.
[D] By invoking the special getter methods on the ResultSet: getString(...), getBoolean
(...), getClob(...)

Answer: D. By invoking the special getter methods on the ResultSet: getString(...),


getBoolean (...), getClob(...)

Explanation: ResultSet is the statement to get the string value , getBoolean, to the
query.
18. How can you execute a stored procedure in the database?
[A] Call method execute() on a CallableStatement object
[B] Call method executeProcedure() on a Statement object
[C] Call method execute() on a StoredProcedure object
[D] Call method run() on a ProcedureCommand object

Answer: A. Call method execute() on a CallableStatement object

Explanation: you can execute the procedure by execute() method

19. What happens if you call the method close() on a ResultSet object?
[A] the method close() does not exist for a ResultSet. Only Connections can be closed.
[B] the database and JDBC resources are released
[C] you will get a SQLException, because only Statement objects can close ResultSets
[D] the ResultSet, together with the Statement which created it and the Connection
from which the Statement was retrieved, will be closed and release all database and
JDBC resources

Answer: B. the database and JDBC resources are released

Explanation: if you call the method close() , jdbc release all the resources.

20. What happens if you call deleteRow() on a ResultSet object?


[A] The row you are positioned on is deleted from the ResultSet, but not from the
database.
[B] The row you are positioned on is deleted from the ResultSet and from the database
[C] The result depends on whether the property synchronizeWithDataSource is set to
true or false
[D] You will get a compile error: the method does not exist because you can not delete
rows from a ResultSet

Answer: B. The row you are positioned on is deleted from the ResultSet and from the
database

Explanation: The row you are positioned on is deleted from the ResultSet and from the
database
21. How many JDBC driver types does Sun define?
[A] one
[B] two
[C] three
[D] four

Answer: D. four

Explanation: There are four JDBC driver.

22. ………………… is a full form of SQL. 1M


A. Standard query language
B. Sequential query language
C. Structured query language
D. Server side query language

Answer : - A

23. Prepared Statement object in JDBC used to execute........... queries. 1M


A. Executable
B. Simple
C. High level
D. Parameterized

Answer : - D

24. executeQuery() method returns_____________________


A. Single row
B. ResultSet object
C. Single Column
D. Database Table

Answer : - B

25. PreparedStatement interface extends____________________ interface


A. Connection
B. Statement
C. ResultSet
D. Driver

Answer : - B
26. executeUpdate() method returns_____________________
A. Single row
B. ResultSet object
C. Integer
D. Single Column

Answer : - C

27.Rearrange the steps to connect to the database in SQL. 2M


A. Create the connection object
B. Execute the query
C. Close the connection object
D. Register the driver class
E. Create the statement object

A. a-b-c-d-e
B. d-a-e-b-c
C. e-d-c-b-a
D. d-a-c-b-e

Answer : - B:

28. Native – protocol pure Java converts ……….. in to the ………… used by DBMSs
directly.
A. JDBC calls, network protocol
B. ODBC class, network protocol
C. ODBC class, user call
D. JDBC calls, user call
Answer: A: JDBC calls, network protocol

29. The JDBC-ODBC bridge driver resolves……….. and makes equivalent ………..
A. JDBC call, ODBC call
B. ODBC call, ODBC call
C. ODBC call, JDBC call
D. JDBC call, JDBC call
Answer: A: JDBC call, ODBC call
30. For execution of DELETE SQL query in JDBC, ............. method must be used.
A. executeQuery()
B. executeDeleteQuery()
C. executeUpdate()
D. executeDelete()
Answer: C: executeUpdate()

31. Prepared Statement object in JDBC used to execute........... queries.


A. Executable
B. Simple
C. High level
D. Parameterized

Answer: D: Parameterized

You might also like