wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

JDBC

Total questions: 20

Worksheet time: 15mins

Name
Class
Date
1.

Which driver is efficient and always preferable for using JDBC applications?

a)

Type-4

b)

Type-3

c)

Type-2

d)

Type-1

2.

Which JDBC driver Type(s) is(are) the JDBC-ODBC bridge?

a)

Type 1

b)

Type 2

c)

Type 3

d)

Type 4

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

4.

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)

5.

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(…), getInt (…), getDouble(…),…

6.

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

7.

Which method is used to perform DML statements in JDBC?

a)

execute()

b)

executeQuery()

c)

executeUpdate()

d)

executeResult()

8.

Which of the following is correct about PreparedStatement?

a)

Prepared statements offer better performance, as they are pre-compiled.

b)

Prepared statements reuse the same execution plan for different arguments rather than creating a new execution plan every time.

c)

Prepared statements use bind arguments, which are sent to the database engine.

d)

All of the above.

9.

In order to transfer data between a database and an application written in the Java programming language, the JDBC API provides which of these methods?

a)

Methods on the ResultSet class for retrieving SQL SELECT results as Java types.

b)

Methods on the PreparedStatement class for sending Java types as SQL statement parameters.

c)

Methods on the CallableStatement class for retrieving SQL OUT parameters as Java types.

d)

All mentioned above

10.

The performance of the application will be faster if you use PreparedStatement interface because query is compiled only once.

a)

True

b)

False

11.

Which method is used to establish the connection with the specified url in a Driver Manager class?

a)

public static void registerDriver(Driver driver)

b)

public static void deregisterDriver(Driver driver)

c)

public static Connection getConnection(String url)

d)

public static Connection getConnection(String url,String userName,String password)

12.

Which driver Network connection is indirect that a JDBC client makes to a middleware process that acts as a bridge to the DBMS server?

a)

JDBC-Net

b)

JDBC-ODBC bridge

c)

Native API as basis

d)

Native protocol as basis

13.

Which is used to call the stored procedures and functions?

a)

CallableStatement Interface

b)

PreparedStatement Interface

c)

All the above

d)

None of the above

14.

What is used to execute parameterized query?

a)

Statement interface

b)

PreparedStatement interface

c)

ResultSet interface

d)

None of the above

15.

ODBC stands for?

a)

Open database connection

b)

Open database concept

c)

Open database communications

d)

None of the above

16.

Which models do the JDBC API support for the database access?

a)

Two-tier models

b)

Three-tier models

c)

Both A & B

d)

None of the above

17.

Which of the following is used to rollback a JDBC transaction?

a)

rollback()

b)

rollforward()

c)

deleteTransaction()

d)

RemoveTransaction()

18.

The method on the result set that tests whether or not there remains at least one unfetched tuple in the result set, is said to be

a)

Fetch method

b)

Current method

c)

Next method

d)

Access method

19.

Which method is used to perform DML statements in JDBC?

a)

execute()

b)

executeQuery()

c)

executeUpdate()

d)

executeResult()

20.

Which of the following describes the correct sequence of the steps involved in making a connection with a database.

1. Loading the driver

2. Process the results.

3. Making the connection with the database.

4. Executing the SQL statements.

a)

1 ,3,4,2

b)

1,2,3,4

c)

1,4,3,2

d)

1,2,4,3