Anda di halaman 1dari 68

0.0/ 5.

0 Points

Question 1 of 20
The ______ interface communicates with the database, either directly or thought another database specific
driver. ?

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

Question 2 of 20
Which java.sql class provides the getConnection() method?

5.0/ 5.0 Points

A. ResultSet 71
B. Connection
C. DriverManager
D. Driver

5.0/ 5.0 Points

Question 3 of 20
Which java.sql class or interface is used to create the object that is necessary for calling stored procedures?

A. CallableStatement
B. Statement
C. ResultSet

D. PreparedStatement

5.0/ 5.0 Points

Question 4 of 20
If one intends to work with a ResultSet, which of these PreparedStatement methods will not work?

A. executeUpdate()
B. executeQuery()
C. execute()

Question 5 of 20
What is, in terms of JDBC, a DataSource

5.0/ 5.0 Points

A. A DataSource is a factory of connections to a physical data source


B. A DataSource is a registry point for JNDI-services
C. A DataSource is the basic service for managing a set of JDBC drivers
D. A DataSource is the Java representation of a physical data source

Question 6 of 20
The methods of what type of object can be used to move the cursor through a result set? ?

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

0.0/ 5.0 Points

Question 7 of 20
Which of the following describes a JDBC type 4 driver?

0.0/ 5.0 Points

A. JDBC-ODBC bridge plus ODBC driver


B. Native-API partly Java driver
C. Native-protocol pure Java driver
D. JDBC-Net pure Java driver

Question 8 of 20
Are prepared statements actually compiled

5.0/ 5.0 Points

A. Yes, they compiled


B. No, they are bound by the JDBC driver

Question 9 of 20
What is correct about DDL statements (create, grant,...)

5.0/ 5.0 Points

A. DDL statements are treated as normal SQL statements, and are executed by calling the
execute() method on a Statement (or a sub interface thereof) object
B. DDL statements cannot be executed by making use of JDBC, you should use the native
database tools for this.
C. Support for DDL statements will be a feature of a future release of JDBC
D. To execute DDL statements, you have to install additional support files

Question 10 of 20

5.0/ 5.0 Points

A method that takes a Student object and writes it to the Student table in a database implements
___________. ?

A. ResultSetMetaData
B. connection pooling
C. OR mapping (object to relational)
D. init, destroy

Question 11 of 20
What is the meaning of ResultSet.TYPE_SCROLL_INSENSITIVE

5.0/ 5.0 Points

A. This means that the ResultSet is sensitive to scrolling, but insensitive to changes made
by others
B. This means that the Resultset is sensitive to scrolling, but insensitive to updates, i.e. not
updateable
C. The meaning depends on the type of data source, and the type and version of the driver
you use with this data source
D. This means that the ResultSet is insensitive to scrolling

Question 12 of 20
Which of following is wrong about CallableStatement

0.0/ 5.0 Points

A. The object of CallableStatement class can be created using


Connection.createCallableStatement() method.
B. The object of CallableStatement class can be created using Connection.prepareCall()
method.

C. This interface is used to execute SQL stored procedures.


D. This extends PreparedStatement interface.

Question 13 of 20
Are ResultSets updateable

5.0/ 5.0 Points

A. Yes, but only if you indicate a concurrency strategy when executing the statement, and
if the driver and database support this option
B. Yes, but only if you call the method openCursor() on the ResultSet, and if the driver and
database support this option
C. No, ResultSets are never updateable. You must explicitly execute DML statements
(i.e.insert, delete and update) to change the data in the underlying database.
D. Yes, but only if the ResultSet is an object of class UpdateableResultSet, and if the driver
and database support this option
Question 14 of 20
What statements are correct about positioned updates (i.e. cursor updates) in ResultSets

5.0/ 5.0 Points

A.Only scrollable updateable ResultSets can use this approach to change the data in the
current row of a ResultSet
B.The name of the cursor is specified by the setCursorName(String name) method the
Statement object.
C.Using the cursor technique is currently the only possible way to change the data in the
current row of a ResultSet
D.Insert statements are only supported when using scrollable cursors.

Question 15 of 20

0.0/ 5.0 Points

When the message No Suitable Driver occurs

A. When the type 4 driver is used


B. When the user name, password and the database does not match
C. When the driver is not registered by Class.forname() method
D. When the JDBC database URL passed is not constructed properly

Question 16 of 20
How is the forName() method of the "Class" class used with JDBC?

5.0/ 5.0 Points

A. To load a JDBC driver


B. To establish a database connection
C. To execute a SQL statementresses
D. To load a result set

Question 17 of 20
How can you execute DML statements (i.e. insert, delete, update) in the database

5.0/ 5.0 Points

A. By invoking the executeInsert(...), executeDelete(...) or executeUpdate(...) methods of


the DataModificationStatement object
B. By invoking the execute(...) or executeUpdate(...) method of a normal Statement object
or a sub-interface object thereof
C. By making use of the InsertStatement, DeleteStatement or UpdateStatement classes
D. By making use of the execute(...) statement of the DataModificationStatement object

5.0/ 5.0 Points

Question 18 of 20
What a correct ordering of steps should be to using a updatable recordset to insert new customers into the
Customer table.
A. Prompt user for customer information
B. Call set methods for each column using customer information
C. Execute statement S3 selecting the Customer table, return result set R1
D. Close S3
E. Ask if more customers to add, if so go back to ""Prompt user""
F. Close connection
G. Open connection to database
H. Close R1
I. Create statement S3 using SCROLLABLE and UPDATABLE flags
J. Go to insert row of R1
K. Call R1.insertRow

A. I_G_C_J_A_B_E_K_H_D_F
B. G_I_C_J_A_B_K_E_D_H_F
C. G_I_C_J_A_B_K_E_H_D_F
D. I_G_C_J_A_B_K_E_H_D_F

5.0/ 5.0 Points

Question 19 of 20
Which of the following statements will delete all records from the Invoices table that have a value of 0 in the
InvoiceTotal field?
String query = ""DELETE FROM Invoices "" + ""WHERE InvoiceTotal = 0 "";
Statement statement = connection.createStatement();

A. statement.deleteRows(query);
B. statement.delete(query);
C. statement.executeQuery(query);
D. statement.executeUpdate(query);

Question 20 of 20
Which driver is called as thin-driver in JDBC

5.0/ 5.0 Points

A. Type-3 driver
B. Type-2 driver
C. Type-4 driver
D. Type-1 driver

Question 1 of 20

5.0/ 5.0 Points

Are prepared statements actually compiled

A. Yes, they compiled

B. No, they are bound by the JDBC driver

Question 2 of 20
Which interface of the JDBC API executes pre-compiled SQL statements?

A. Resultset

B. Statement

5.0/ 5.0 Points

C. PreparedStatement

Question 3 of 20

5.0/ 5.0 Points

Which java.sql class or interface is used to create a Statement object? ?

A. Connection

B. Driver

C. DriverManager

D. ResultSet

Question 4 of 20
How is the forName() method of the "Class" class used with JDBC?

A. To load a JDBC driver

B. To establish a database connection

5.0/ 5.0 Points

C. To execute a SQL statementresses

D. To load a result set

Question 5 of 20

0.0/ 5.0 Points

A ________ object is used to submit a query to a database. ?

A. java.sql

B. Connection.

C. dataset

D. Statement.

Question 6 of 20
_______ helps manage the connection between the Java program and the database. ?

A. ResultSet

0.0/ 5.0 Points

B. Statement.

C. Connection.

D. java.sql

Question 7 of 20

5.0/ 5.0 Points

What statements are correct about batched insert and updates? (2 correct answers)

A.To do a batched update/insert, you call addBatch(String statement) on a


Statement object for each statement you want to execute in the batch
B.Batch insert and updates are only possible when making use of
parameterized queries.
C.To execute a batched update/insert, you call the executeBatch() method on a
Statement object
D.To create a batch of insert and update statements, you create an object of
type Batch, and call the method addStatement(String statement) for each
statement you want to execute in the batch

Question 8 of 20

5.0/ 5.0 Points

How can you execute DML statements (i.e. insert, delete, update) in the database

A. By invoking the executeInsert(...), executeDelete(...) or executeUpdate(...)


methods of the DataModificationStatement object
B. By invoking the execute(...) or executeUpdate(...) method of a normal
Statement object or a sub-interface object thereof
C. By making use of the InsertStatement, DeleteStatement or
UpdateStatement classes
D. By making use of the execute(...) statement of the
DataModificationStatement object

Question 9 of 20

5.0/ 5.0 Points

Are ResultSets updateable

A. Yes, but only if you indicate a concurrency strategy when executing the
statement, and if the driver and database support this option
B. Yes, but only if you call the method openCursor() on the ResultSet, and if the
driver and database support this option
C. No, ResultSets are never updateable. You must explicitly execute DML

statements (i.e.insert, delete and update) to change the data in the underlying
database.
D. Yes, but only if the ResultSet is an object of class UpdateableResultSet, and
if the driver and database support this option

Question 10 of 20

5.0/ 5.0 Points

When you code an inner join in a SELECT statement you do not need to specify ?

A. an ORDER BY clause

B. a join column for the first table

C. the name of the second table

D. a join column for the second table

Question 11 of 20
Which type of Statement can execute parameterized queries

A. ParameterizedStatement

5.0/ 5.0 Points

B. ParameterizedStatement and CallableStatement

C. PreparedStatement

D. All kinds of Statements (i.e. which implement a sub interface of Statement)

Question 12 of 20

0.0/ 5.0 Points

After a SELECT statement, a _________ is a logical table that's created temporarily within the database. ?

A. recordset

B. dataset

C. result set

D. datareader

Question 13 of 20
The result set retrieved by the following SELECT statement contains records that have
SELECT Balance, Num
FROM Accounts
WHERE Balance < 0

5.0/ 5.0 Points

A. two fields from the Balance table where Account Num is less than 0

B. one field from the Balance table where Account Num is less than 0

C. two fields from the Accounts table where Balance is less than 0

D. all fields from the Accounts table where Balance is less than 0

Question 14 of 20

5.0/ 5.0 Points

If one intends to work with a ResultSet, which of these PreparedStatement methods will not work?

A. executeUpdate()

B. executeQuery()

C. execute()

Question 15 of 20
Which of arguments are used by DriverManager.getConnection() (2 correct answers)

5.0/ 5.0 Points

A.databaseName: The database name

B.url: Database url where stored or created your database

C.userName: User name

D.portNumber: the port number

Question 16 of 20
Which of following is wrong about CallableStatement

A. The object of CallableStatement class can be created using


Connection.createCallableStatement() method.
B. The object of CallableStatement class can be created using
Connection.prepareCall() method.
C. This interface is used to execute SQL stored procedures.

D. This extends PreparedStatement interface.

5.0/ 5.0 Points

Question 17 of 20

5.0/ 5.0 Points

What happens if you call the method close() on a ResultSet object

A. You will get a SQLException, because only Statement objects can close
ResultSets
B. 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
C. The method close() does not exist for a ResultSet. Only Connections can be
closed.
D. The database and JDBC resources are released

Question 18 of 20
Which driver is called as thin-driver in JDBC

A. Type-3 driver

B. Type-2 driver

5.0/ 5.0 Points

C. Type-4 driver

D. Type-1 driver

Question 19 of 20

5.0/ 5.0 Points

What is the meaning of the transaction isolation level TRANSACTION_REPEATABLE_READ

A. Dirty reads are prevented; non-repeatable reads and phantom reads can
occur
B. Dirty reads, non-repeatable reads and phantom reads can occur

C. Dirty reads and non-repeatable reads are prevented; phantom reads can
occur
D. Dirty reads, non-repeatable reads and phantom reads are prevented

Question 20 of 20
Which of the following describes a JDBC type 4 driver?

A. JDBC-ODBC bridge plus ODBC driver

5.0/ 5.0 Points

B. Native-API partly Java driver

C. Native-protocol pure Java driver

D. JDBC-Net pure Java driver

Question 1 of 20

5.0/ 5.0 Points

What statements are correct about batched insert and updates? (2 correct
answers)

A.To do a batched update/insert, you call addBatch(String statement) on a


Statement object for each statement you want to execute in the batch
B.Batch insert and updates are only possible when making use of
parameterized queries.
C.To execute a batched update/insert, you call the executeBatch() method on a
Statement object
D.To create a batch of insert and update statements, you create an object of
type Batch, and call the method addStatement(String statement) for each
statement you want to execute in the batch

Question 2 of 20

5.0/ 5.0 Points

Which java.sql class or interface is used to create the object that is necessary for
calling stored procedures?

A. CallableStatement

B. Statement

C. ResultSet

D. PreparedStatement

Question 3 of 20

5.0/ 5.0 Points

How many transaction isolation levels are defined in java.sql.Connection interface

A. 5

B. 4

C. 2

D. 3

Question 4 of 20

5.0/ 5.0 Points

A method that takes a Student object and writes it to the Student table in a
database implements ___________. ?

A. ResultSetMetaData

B. connection pooling

C. OR mapping (object to relational)

D. init, destroy

Question 5 of 20

5.0/ 5.0 Points

What statements are correct about positioned updates (i.e. cursor updates) in
ResultSets

A.Only scrollable updateable ResultSets can use this approach to change the
data in the current row of a ResultSet
B.The name of the cursor is specified by the setCursorName(String name)
method the Statement object.

C.Using the cursor technique is currently the only possible way to change the
data in the current row of a ResultSet
D.Insert statements are only supported when using scrollable cursors.

Question 6 of 20

5.0/ 5.0 Points

In Java, the result of a SQL query is returned in a ____ object. ?

A. ResultSet

B. JDBC

C. Command

D. Connection

Question 7 of 20

0.0/ 5.0 Points

The JDBC-ODBC Bridge supports multiple concurrent open statements per


connection

A. No

B. Yes

Question 8 of 20

5.0/ 5.0 Points

What statements are correct about JDBC transactions (2 correct answers)?

A.A transaction is a set of successfully executed statements in the database

B.A transaction is finished when commit() or rollback() is called on the


Connection object,
C.A transaction is finished when commit() or rollback() is called on the
Transaction object
D.A transaction is finished when close() is called on the Connection object

Question 9 of 20

Which of the following is NOT a way to insert data into a table?

A. an INSERT statement

B. a configuration file

0.0/ 5.0 Points

C. a SQL script

D. a LOAD command

Question 10 of 20

5.0/ 5.0 Points

Which packages contain the JDBC classes

A. java.jdbc and java.jdbc.sql

B. java.sql and javax.sql

C. java.jdbc and javax.jdbc

D. java.rdb and javax.rdb

Question 11 of 20

5.0/ 5.0 Points

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 query the ResultSet object about possible warnings generated by
the database
C. You must invoke the getWarnings() method on the Statement object (or a
sub interface thereof)
D. You must catch the unchecked SQLWarningException which is thrown by the
method which executes the statement

Question 12 of 20

jdbc.drivers = sun.jdbc.odbc.JdbcOdbcDriver
The Above statement:
1. loads the JDBC-ODBC bridge drivers
2. unloads the JDBC-ODBC bridge drivers

A. 1 and 2 are true.

B. 1 and 2 are false

C. 1 is true, 2 is false.

D. 1 is false, 2 is true.

5.0/ 5.0 Points

Question 13 of 20

5.0/ 5.0 Points

Which of the following methods finds the maximum number of connections that a
specific driver can obtain

A. DatabaseMetaData.getMaxConnections

B. Database.getMaxConnections

C. Connection.getMaxConnections

D. ResultSetMetaData.getMaxConnections

Question 14 of 20

Which driver is called as thin-driver in JDBC

A. Type-3 driver

B. Type-2 driver

C. Type-4 driver

5.0/ 5.0 Points

D. Type-1 driver

Question 15 of 20

5.0/ 5.0 Points

JDBC defines Java Classes for: ?

A. Result sets

B. All of the other answers

C. Database metadata, Database connection

D. SQL statements

Question 16 of 20

5.0/ 5.0 Points

How can you execute DML statements (i.e. insert, delete, update) in the database

A. By invoking the executeInsert(...), executeDelete(...) or executeUpdate(...)


methods of the DataModificationStatement object
B. By invoking the execute(...) or executeUpdate(...) method of a normal

Statement object or a sub-interface object thereof


C. By making use of the InsertStatement, DeleteStatement or
UpdateStatement classes
D. By making use of the execute(...) statement of the
DataModificationStatement object

Question 17 of 20

5.0/ 5.0 Points

What is the meaning of ResultSet.TYPE_SCROLL_INSENSITIVE

A. This means that the ResultSet is sensitive to scrolling, but insensitive to


changes made by others
B. This means that the Resultset is sensitive to scrolling, but insensitive to
updates, i.e. not updateable
C. The meaning depends on the type of data source, and the type and version
of the driver you use with this data source
D. This means that the ResultSet is insensitive to scrolling

Question 18 of 20

5.0/ 5.0 Points

Which java.sql class or interface contains methods that enable you to find out the

number of columns this is returned in a ResultSet and the name or label for a given
column? ?

A. Statement

B. MetaData

C. CallableStatement

D. ResultSetMetaData

Question 19 of 20

5.0/ 5.0 Points

When you code an inner join in a SELECT statement you do not need to specify ?

A. an ORDER BY clause

B. a join column for the first table

C. the name of the second table

D. a join column for the second table

Question 20 of 20

5.0/ 5.0 Points

Which driver is efficient and always preferable for using JDBC applications

A. Type 1

B. Type 2

C. Type 4

D. Type 3

5.0/ 5.0 Points


Question 1 of 20

The column index of ResultSet object is numbered from _________

A. Yes

B. No

Question 2 of 20

0.0/ 5.0 Points

After a SELECT statement, a _________ is a logical table that's created temporarily within the database. ?

A. result set

B. datareader

C. recordset

D. dataset

Question 3 of 20

5.0/ 5.0 Points

Which statements about JDBC are true (2 correct answers)

A.JDBC is an API to connect to relational-, object- and XML data sources

B.JDBC is an API to bridge the object-relational mismatch between OO


programs and relational databases
C.JDBC is an API to access relational databases, spreadsheets and flat files

D.JDBC stands for Java DataBase Connectivity

Question 4 of 20

0.0/ 5.0 Points

The different types of JDBC driver are

A.Native-API, partly Java driver

B.Native-API, pure Java driver

C.Jdbc-odbc bridge, plus odbc driver

D.Jdbc-net, pure Java driver

Question 5 of 20

5.0/ 5.0 Points

Which java.sql class or interface contains methods that enable you to find out the number of columns this is
returned in a ResultSet and the name or label for a given column? ?

A. Statement

B. MetaData

C. CallableStatement

D. ResultSetMetaData

Question 6 of 20

5.0/ 5.0 Points

Which method is used to perform DML statements in JDBC

A. executeQuery()

B. executeResult()

C. executeUpdate()

D. execute()

5.0/ 5.0 Points


Question 7 of 20

What happens if you call the method close() on a ResultSet object

A. 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
B. You will get a SQLException, because only Statement objects can close
ResultSets
C. The database and JDBC resources are released

D. The method close() does not exist for a ResultSet. Only Connections can be
closed.

Question 8 of 20
Which driver is called as thin-driver in JDBC

A. Type-2 driver

B. Type-3 driver

C. Type-4 driver

5.0/ 5.0 Points

D. Type-1 driver

Question 9 of 20

5.0/ 5.0 Points

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. You will get a compile error: the method does not exist because you can not
delete rows from a ResultSet
D. The result depends on whether the property synchronizeWithDataSource is
set to true or false

Question 10 of 20

5.0/ 5.0 Points

How can you retrieve information from a ResultSet

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


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

B. By invoking the method getValue(...), and cast the result to the desired Java
type.
C. By invoking the method get(..., Type type) on the ResultSet, where Type is
an object which represents a database type
D. By invoking the method get(..., String type) on the ResultSet, where type is
the database type

Question 11 of 20

5.0/ 5.0 Points

Are ResultSets updateable

A. Yes, but only if you indicate a concurrency strategy when executing the
statement, and if the driver and database support this option
B. Yes, but only if the ResultSet is an object of class UpdateableResultSet, and
if the driver and database support this option
C. Yes, but only if you call the method openCursor() on the ResultSet, and if the
driver and database support this option
D. No, ResultSets are never updateable. You must explicitly execute DML
statements (i.e.insert, delete and update) to change the data in the underlying
database.

Question 12 of 20

5.0/ 5.0 Points

To improve the performance of database operations, an application can use _________ where a limited
number of connections are opened and are shared by users of the database. ?

A. ResultSetMetaData

B. OR mapping (object to relational)

C. init

D. connection pooling

Question 13 of 20
Which packages contain the JDBC classes

A. java.jdbc and javax.jdbc

B. java.sql and javax.sql

C. java.jdbc and java.jdbc.sql

5.0/ 5.0 Points

D. java.rdb and javax.rdb

Question 14 of 20

5.0/ 5.0 Points

Which of following is wrong about CallableStatement

A. This interface is used to execute SQL stored procedures.

B. This extends PreparedStatement interface.

C. The object of CallableStatement class can be created using


Connection.prepareCall() method.
D. The object of CallableStatement class can be created using
Connection.createCallableStatement() method.

Question 15 of 20
JDBC defines Java Classes for: ?

A. Database metadata, Database connection

B. Result sets

5.0/ 5.0 Points

C. All of the other answers

D. SQL statements

Question 16 of 20

5.0/ 5.0 Points

The methods of what type of object can be used to move the cursor through a result set? ?

A. ResultSet

B. Statement

C. URL

D. Connection

Question 17 of 20
The JDBC-ODBC bridge is

A. Three tiered

B. Multithreaded

0.0/ 5.0 Points

C. Best for any platform

D. All of the above

Question 18 of 20

5.0/ 5.0 Points

The class java.sql.Timestamp has its super class as

A. java.sql.Time

B. java.util.Date

C. java.util.Time

D. None of the above

Question 19 of 20
Which of these operations are provided by DML Data Manipulation Language? ?

A. Creating & deleting a table

0.0/ 5.0 Points

B. Creating table

C. Inserting data and updating data

D. Encoding the data

Question 20 of 20

5.0/ 5.0 Points

The _______ class is traditional management layer of JDBC, working between the user and the drivers

A. Connection

B. DriverManager

C. Resultset

JDBC Objective Questions

See These Questions


1. Which statements about JDBC are true? (2 answers)
[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,

spreadsheets and flat files


[d] JDBC is an API to bridge the object-relational mismatch
between OO programs and relational
databases
2. 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
3. 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
4. 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
5. Which type of Statement can execute parameterized
queries?
(a) PreparedStatement
(b) ParameterizedStatement
(c) ParameterizedStatement and CallableStatement
(d) All kinds of Statements (i.e. which implement a sub
interface of Statement)
6. 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(...),...
7. How can you execute DML statements (i.e. insert,
delete, update) in the database?
(a) By making use of the InsertStatement,
DeleteStatement or UpdateStatement classes
(b) By invoking the execute(...) or executeUpdate(...)
method of a normal Statement object or a sub-interface
object
thereof
(c) By invoking the executeInsert(...), executeDelete(...) or
executeUpdate(...) methods of the
DataModificationStatement object
(d) By making use of the execute(...) statement of the
DataModificationStatement object
8. 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
9. What is, in terms of JDBC, a DataSource?
(a) A DataSource is the basic service for managing a set
of JDBC drivers
(b) A DataSource is the Java representation of a physical
data source
(c) A DataSource is a registry point for JNDI-services
(d) A DataSource is a factory of connections to a physical
data source
10. What is the meaning of
ResultSet.TYPE_SCROLL_INSENSITIVE
(a) This means that the ResultSet is insensitive to
scrolling
(b) This means that the Resultset is sensitive to scrolling,
but insensitive to updates, i.e. not updateable
(c) This means that the ResultSet is sensitive to scrolling,
but insensitive to changes made by others
(d) The meaning depends on the type of data source, and
the type and version of the driver you use with this
data source

11. Are ResultSets updateable?


(a) Yes, but only if you call the method openCursor() on
the ResultSet, and if the driver and database support
this option
(b) Yes, but only if you indicate a concurrency strategy
when executing the statement, and if the driver and
database support this option
(c) Yes, but only if the ResultSet is an object of class
UpdateableResultSet, and if the driver and database
support thisoption
(d) No, ResultSets are never updateable. You must
explicitly execute DML statements (i.e. insert, delete and
update) to change the data in the underlying database
12. What statements are correct about JDBC transactions
(2 correct answers)?
[a] A transaction is a set of successfully executed
statements in the database
[b] A transaction is finished when commit() or rollback() is
called on the Connection object,
[c] A transaction is finished when commit() or rollback() is
called on the Transaction object
[d] A transaction is finished when close() is called on the
Connection object.

13. How can you start a database transaction in the


database?
(a) By asking a Transaction object to your Connection,
and calling the method begin() on it
(b) By asking a Transaction object to your Connection,
and setting the autoCommit property of the Transaction to
false
(c) By calling the method beginTransaction() on the
Connection object
(d) By setting the autoCommit property of the Connection
to false, and execute a statement in the database
14. What is the meaning of the transaction isolation level
TRANSACTION_REPEATABLE_READ
(a) Dirty reads, non-repeatable reads and phantom reads
can occur
(b) Dirty reads are prevented; non-repeatable reads and
phantom reads can occur
(c) Dirty reads and non-repeatable reads are prevented;
phantom reads can occur
(d) Dirty reads, non-repeatable reads and phantom reads
are prevented
15. What statements are correct about positioned updates
(i.e. cursor updates) in ResultSets? (2

correct answers)
[a] Using the cursor technique is currently the only
possible way to change the data in the current row of a
ResultSet
[b] Insert statements are only supported when using
scrollable cursors.
[c] Only scrollable updateable ResultSets can use this
approach to change the data in the current row of a
ResultSet
[d] The name of the cursor is specified by the
setCursorName(String name) method the Statement
object.
16. 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
17. 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
18. 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
19. What statements are correct about batched insert and
updates? (2 answers)
[a] To create a batch of insert and update statements, you
create an object of type Batch, and call the method
addStatement(String statement) for each statement you
want to execute in the batch
[b] Batch insert and updates are only possible when
making use of parameterized queries.
[c] To do a batched update/insert, you call addBatch(String

statement) on a Statement object for each statement


you want to execute in the batch
[d] To execute a batched update/insert, you call the
executeBatch() method on a Statement object
20. What is correct about DDL statements (create,
grant,...)?
(a) DDL statements are treated as normal SQL
statements, and are executed by calling the execute()
method on a Statement (or a sub interface thereof) object
(b) To execute DDL statements, you have to install
additional support files
(c) DDL statements can not be executed by making use of
JDBC, you should use the native database tools for this.
(d) Support for DDL statements will be a feature of a future
release of JDBC
21. The JDBC-ODBC Bridge supports multiple concurrent
open statements per connection?
a. True
b. False
22. 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
23. 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
24. 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()
25. Which of the following is false as far as type 4 driver is
concern?
a. Type 4 driver is native protocol, pure java driver
b. Type 4 drivers are 100% Java compatible
c. Type 4 drivers uses Socket class to connect to the
database
d. Type 4 drivers can not be used with Netscape

26. To execute a stored procedure totalStock in a


database server, which of the following code snippet is
used?
a. Statement stmt =
connection.createStatement();stmt.execute("totalStock()");
b. CallableStatement clbstmnt = con.prepareCall("{call
totalStock}");cs.executeQuery();
c. StoreProcedureStatement
stmt=connection.createStoreProcedure("totalStock()");spst
mt.executeQuery();
d. PrepareStatement pstmt =
connection.prepareStatement("totalStock()");pstmt.execut
e();
27. Which driver is efficient and always preferable for
using JDBC applications?
a. Type 4
b. Type 1
c. Type 3
d. Type 2
28. JDBC facilitates to store the java objects by using
which of the methods of PreparedStatement
setObject () 2. setBlob() 3. setClob()

a. 1, 2
b. 1,2,3
c. 1,3
d. 2,3
29. Which statement is static and synchronized in JDBC
API?
a. executeQuery()
b. executeUpdate()
c. getConnection()
d. prepareCall()
30. The JDBC-ODBC bridge is
a. Three tiered
b. Multithreaded
c. Best for any platform
d. All of the above
31. All raw data types (including binary documents or
images) should be read and uploaded to the database as
an array of
a. byte
b. int
c. boolean
d. char

32. The class java.sql.Timestamp has its super class as


a. java.sql.Time
b. java.util.Date
c. java.util.Time
d. None of the above
33. BLOB, CLOB, ARRAY and REF type columns can be
updated in
a. JDBC 1.0
b. JDBC 4.0
c. JDBC 2.0
d. JDBC 3.0
34. Which of the following methods finds the maximum
number of connections that a specific driver can obtain?
a. Database.getMaxConnections
b. Connection.getMaxConnections
c. DatabaseMetaData.getMaxConnections
d. ResultSetMetaData.getMaxConnections
35. Are prepared statements actually compiled?
a. Yes, they compiled
b. No, they are bound by the JDBC driver

36. When the message No Suitable Driver occurs?


a. When the driver is not registered by Class.forname()
method
b. When the user name, password and the database does
not match
c. When the JDBC database URL passed is not
constructed properly
d. When the type 4 driver is used
37. Which driver is called as thin-driver in JDBC?
a. Type-4 driver
b. Type-1 driver
c. Type-3 driver
d. Type-2 driver
38. How many transaction isolation levels are defined in
java.sql.Connection interface?
a. 4
b. 3
c. 5
d. 2
39. Which method is used to perform DML statements in

JDBC?
a. execute()
b. executeQuery()
c. executeUpdate()
d. executeResult()
40. What is the disadvantage of Type-4 Native-Protocol
Driver?
a. At client side, a separate driver is needed for each
database.
b. Type-4 driver is entirely written in Java
c. The driver converts JDBC calls into vendor-specific
database protocol
d. It does not support to read MySQL data.
Part 1 of 1 -

Question 1 of 20

100.0/ 100.0 Points

5.0/ 5.0 Points

The ______ interface communicates with the database, either directly or thought
another database specific driver. ?

A. DirectManager

B. Driver

C. Statement

D. Connection

Question 2 of 20

5.0/ 5.0 Points

What is the meaning of the transaction isolation level


TRANSACTION_REPEATABLE_READ

A. Dirty reads, non-repeatable reads and phantom reads can occur

B. Dirty reads, non-repeatable reads and phantom reads are prevented

C. Dirty reads are prevented; non-repeatable reads and phantom reads can
occur
D. Dirty reads and non-repeatable reads are prevented; phantom reads can
occur

Question 3 of 20

5.0/ 5.0 Points

If one intends to work with a ResultSet, which of these PreparedStatement methods


will not work?

A. executeQuery()

B. execute()

C. executeUpdate()

Question 4 of 20

5.0/ 5.0 Points

What is, in terms of JDBC, a DataSource

A. A DataSource is a factory of connections to a physical data source

B. A DataSource is the basic service for managing a set of JDBC drivers

C. A DataSource is a registry point for JNDI-services

D. A DataSource is the Java representation of a physical data source

Question 5 of 20

5.0/ 5.0 Points

To improve the performance of database operations, an application can use


_________ where a limited number of connections are opened and are shared by
users of the database. ?

A. ResultSetMetaData

B. OR mapping (object to relational)

C. init

D. connection pooling

Question 6 of 20

5.0/ 5.0 Points

What is type-1 of JDBC drivers

A. Native-API/partly Java driver (Native)

B. JDBC-ODBC Bridge driver (Bridge)

C. All Java/Net-protocol driver (Middleware)

D. All Java/Native-protocol driver (Pure)

5.0/ 5.0 Points


Question 7 of 20

Conn = Driver Manager.getConnection(jdbc:odbc:Employee,,);


What does the above statement do?

A. Gets connectioned to the employee database.

B. Retrieves data from the employee table.

C. Gets a database connection with the Employee data source.

D. Inidicates that jdbc is to be used in the application.

Question 8 of 20

How is the forName() method of the "Class" class used with JDBC?

A. To execute a SQL statementresses

B. To load a JDBC driver

C. To load a result set

5.0/ 5.0 Points

D. To establish a database connection

Question 9 of 20

5.0/ 5.0 Points

When the message No Suitable Driver occurs

A. When the driver is not registered by Class.forname() method

B. When the type 4 driver is used

C. When the JDBC database URL passed is not constructed properly

D. When the user name, password and the database does not match

Question 10 of 20

5.0/ 5.0 Points

The methods of what type of object can be used to move the cursor through a
result set? ?

A. ResultSet

B. Statement

C. URL

D. Connection

Question 11 of 20

5.0/ 5.0 Points

Which java.sql class provides the getConnection() method?

A. ResultSet 71

B. Connection

C. DriverManager

D. Driver

Question 12 of 20

5.0/ 5.0 Points

A method that takes a Student object and writes it to the Student table in a
database implements ___________. ?

A. init, destroy

B. OR mapping (object to relational)

C. connection pooling

D. ResultSetMetaData

Question 13 of 20

5.0/ 5.0 Points

All raw data types (including binary documents or images) should be read and
uploaded to the database as an array of

A. Boolean

B. int

C. byte

D. Char

Question 14 of 20

5.0/ 5.0 Points

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

Question 15 of 20

5.0/ 5.0 Points

What statements are correct about positioned updates (i.e. cursor updates) in
ResultSets

A.Only scrollable updateable ResultSets can use this approach to change the
data in the current row of a ResultSet
B.Using the cursor technique is currently the only possible way to change the
data in the current row of a ResultSet
C.Insert statements are only supported when using scrollable cursors.

D.The name of the cursor is specified by the setCursorName(String name)

method the Statement object.

Question 16 of 20

5.0/ 5.0 Points

What a correct ordering of steps should be to updating the Orders and the
Customers tables, all within the same transaction:
A. Commit
B. Close S1
C. execute S1
D. Create a statement S1 to update Orders
E. Create a statement S2 to update Customers
F. execute S2
G. Close connection
H. Close S2
I. Open connection to the database
J. Set auto commit to false
K. Set auto commit to true

A. I_D_E_C_J_F_A_B_H_K_G

B. I_D_E_J_C_F_A_B_H_K_G

C. I_E_D_J_C_F_A_B_H_K_G

D. I_D_E_J_C_F_A_B_H_G_K

Question 17 of 20

Which type of Statement can execute parameterized queries

5.0/ 5.0 Points

A. PreparedStatement

B. All kinds of Statements (i.e. which implement a sub interface of Statement)

C. ParameterizedStatement and CallableStatement

D. ParameterizedStatement

Question 18 of 20

5.0/ 5.0 Points

Which of the following methods are needed for loading a database driver in JDBC

A. registerDriver() method

B. Both A and B

C. getConnection()

D. Class.forName()

5.0/ 5.0 Points


Question 19 of 20

A file that stores one or more SQL statements is known as a _________. ?

A. SQL script

B. result set

C. connection

D. SQL statement

Question 20 of 20

In Java, the result of a SQL query is returned in a ____ object. ?

A. JDBC

B. Connection

C. Command

5.0/ 5.0 Points

D. ResultSet

Anda mungkin juga menyukai