wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

WTN_JDBC

Total questions: 50

Worksheet time: 25mins

Name
Class
Date
1.

Which of the following tasks are associated with JDBC library?

a)

Making a connection to a database.

b)

Creating SQL or MySQL statements.

c)

Executing SQL or MySQL queries in the database.

d)

All of these

2.

Expand JDBC

(a)  

3.

_____________ interface handles the communications with the database server

a)

DriverManager

b)

Driver

c)

Statement

d)

None of these

4.

___________ interface with all methods for contacting a database.

a)

ResultSet

b)

Statement

c)

Connection

d)

Driver

5.

The third step involved in JDBC application is ____________

a)

Execute Query

b)

Establish Connection

c)

importing packages

d)

Register the Driver

6.

In Type 2 Driver, JDBC API calls are converted into native _____________ API calls, which are unique to the database

a)

C/C++

b)

Java

c)

JavaScript

d)

Visual Programming

7.

Type 4 Driver is also called as (a)  

8.

_____________ driver talks with server-side middleware which then talks to the database

a)

Type 1

b)

Type 2

c)

Type 3

d)

Type 4

9.

(a)   should be imported to use SQL statements

10.

The most common approach to register a driver is to use Java's (a)   method.

11.

To open a connection, DriverManager. (a)   () is to be used.

12.

Which method returns an integer as its result?

a)

execute()

b)

executeUpdate()

c)

executeQuery()

d)

extract()

13.

Which interface will NOT accept input parameters

a)

Statement

b)

PreparedStatement

c)

CallableStatement

d)

PrepareStatement

14.

All parameters in JDBC are represented by the ? symbol, which is known as the (a)   .

15.

in a ResultSet object, the ___________ methods to retrieve the value of a given column.

a)

POST()

b)

GET()

c)

setXXX()

d)

getXXX()

16.

We bind values to _________ parameters with the setXXX methods

a)

OUT

b)

IN

c)

INPUT

d)

OUTPUT

17.

The corresponding SQL type for the boolean JAVA type is_____

a)

BOOLEAN

b)

BIT

c)

BOOL

d)

BYTE

18.

(a)   method returns the total number of columns in the ResultSet object.

19.

_____________interface is used to execute stored procedures.

a)

Statement

b)

PreparedStatement

c)

CallableStatement

d)

execute

20.

(a)   method is used to create an object of the class ResultSetMetaData.

21.

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

22.

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)

23.

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

24.

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

25.

Which method is used to perform DML statements in JDBC?

a)

execute()

b)

executeQuery()

c)

executeUpdate()

d)

executeResult()

26.

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.

27.

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

28.

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

a)

True

b)

False

29.

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)

30.

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

31.

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

32.

What is used to execute parameterized query?

a)

Statement interface

b)

PreparedStatement interface

c)

ResultSet interface

d)

None of the above

33.

ODBC stands for?

a)

Open database connection

b)

Open database concept

c)

Open database communications

d)

None of the above

34.

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

35.

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

a)

rollback()

b)

rollforward()

c)

deleteTransaction()

d)

RemoveTransaction()

36.

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

37.

Which method is used to perform DML statements in JDBC?

a)

execute()

b)

executeQuery()

c)

executeUpdate()

d)

executeResult()

38.

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

39.

Which of the following required to be closed to close database operations?

a)

ResultSet

b)

Statement

c)

Connection

d)

All of the above.

40.

What does the Class.forName("MyClass") do?

a)

Loads the class MyClass.

b)

Execute any static block code of MyClass.

c)

Returns an instance of MyClass.

d)

All of the above.

41.

Which of the following contains both date and time?

a)

java.io.date

b)

java.sql.date

c)

java.util.date

d)

java.util.dateTime

42.

What is the output when run with a JDBC 4.0 driver if the "demo" database exists and contains an empty "users" table?

a)

0

b)

1

c)

The code does not compile.

d)

The code compiles but throws an exception at runtime.

43.

Which resources have their close() method called when this code runs?

a)

No close() methods are called.

b)

Only Statement

c)

Only Statement and Connection

d)

Only Statement and ResultSet

44.

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

45.

Which packages contain the JDBC classes?

a)

java.sql.jdbc

b)

java.sql

c)

javax.sql

d)

java.jdbc.sql

46.

_____________ interface handles the communications with the database server

a)

DriverManager

b)

Driver

c)

Statement

d)

None of these

47.

The most common approach to register a driver is to use Java's ___________method.

a)

Class.forName();

b)

Class.forName;

c)

class.forname();

d)

Class.Forname();

48.

To open a connection, DriverManager._____________________() is to be used.

a)

getConnection

b)

getConnectivity

c)

getManager

d)

None of the above

49.

___________ method returns the total number of columns in the ResultSet object.

a)

getColumnCount()

b)

getColumnCount

c)

getColumnName()

d)

getColumnName

50.

_______________ method is used to create an object of the class ResultSetMetaData.

a)

getMetaData()

b)

getMetaData

c)

Both a and b

d)

None of the above