wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

JDBC

Total questions: 67

Worksheet time: 34mins

Name
Class
Date
1.

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

2.

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)

3.

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

4.

Expand JDBC

(a)  

5.

_____________ interface handles the communications with the database server

a)

DriverManager

b)

Driver

c)

Statement

d)

None of these

6.

___________ interface with all methods for contacting a database.

a)

ResultSet

b)

Statement

c)

Connection

d)

Driver

7.

The third step involved in JDBC application is ____________

a)

Execute Query

b)

Establish Connection

c)

importing packages

d)

Register the Driver

8.

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

9.

Type 4 Driver is also called as (a)  

10.

(a)   should be imported to use SQL statements

11.

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

12.

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

13.

Which method returns an integer as its result?

a)

execute()

b)

executeUpdate()

c)

executeQuery()

d)

extract()

14.

Which interface will NOT accept input parameters

a)

Statement

b)

PreparedStatement

c)

CallableStatement

d)

PrepareStatement

15.

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

16.

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

a)

POST()

b)

GET()

c)

setXXX()

d)

getXXX()

17.

We bind values to _________ parameters with the setXXX methods

a)

OUT

b)

IN

c)

INPUT

d)

OUTPUT

18.

The corresponding SQL type for the boolean JAVA type is_____

a)

BOOLEAN

b)

BIT

c)

BOOL

d)

BYTE

19.

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

20.

_____________interface is used to execute stored procedures.

a)

Statement

b)

PreparedStatement

c)

CallableStatement

d)

execute

21.

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

22.

What is the return type of executeQuery() method?

a)

int

b)

ResultSet

c)

array

d)

none of the above

23.

what is the package name of "Class"?

a)

java.util

b)

java.sql

c)

java.lang

d)

java.io

24.

What is the return type of executeUpdate() method?

a)

byte

b)

short

c)

int

d)

long

25.

What is true about DriverManager class?

a)

It is class from java.lang package

b)

It is a class from java.sql package

c)

It is a interface from java.sql package

d)

It is a class from java.lang package

26.

Which of the following encapsulates an SQL statement which is passed to the database to be parsed, compiled, planned and executed?

a)

DriverManager

b)

JDBC driver

c)

Connection

d)

Statement

27.

Which of the following is correct about PreparedStatement?

a)

Used when you plan to use the SQL statements many times.

b)

The PreparedStatement interface accepts input parameters at runtime.

c)

Both of the above.

d)

None of the above.

28.

what is true about getConnection() method?

a)

It is a static method from DriverManager class

b)

It is a non static method from DriverManager class

c)

It is a static method from DriverManager interface

d)

It is a non static method from DriverManager interface

29.

Which package contains JDBC classes and interfaces?

a)

java.lang

b)

java.io

c)

java.sql

d)

java.jdbc

30.

Which method is used for an SQL statement that is executed frequently?

a)

prepareStatement

b)

prepareCall

c)

createStatement

d)

None of the above

31.

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

a)

ResultSet

b)

Statement

c)

Connection

d)

All of the above.

32.

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.

33.

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

34.

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.

35.

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

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 packages contain the JDBC classes?

a)

java.sql.jdbc

b)

java.sql

c)

javax.sql

d)

java.jdbc.sql

38.

Which packages contain the JDBC classes?

a)

java.sql.jdbc

b)

java.sql

c)

javax.sql

d)

java.jdbc.sql

39.

Which method is used to execute DML statements in JDBC?

a)

execute()

b)

executeUpdate()

c)

executeQuery()

d)

prepareStatement

40.
Which of the following is advantage of using PreparedStatement in Java?
a)
Slow performance
b)
Encourages SQL injection
c)
Prevents SQL injection
d)
More memory usage
41.
Which one of the following contains date information?
a)
java.sql.TimeStamp
b)
java.sql.Time
c)
java.io.Time
d)
java.io.TimeStamp
42.
What does setAutoCommit(false) do?
a)
commits transaction after each query
b)
explicitly commits transaction
c)
does not commit transaction automatically after each query
d)
never commits transaction
43.
Which of the following is used to call stored procedure?
a)
Statement
b)
PreparedStatement
c)
CallableStatment
d)
CalledStatement
44.
Which of the following is used to limit the number of rows returned?
a)
setMaxRows(int i)
b)
setMinRows(int i)
c)
getMaxrows(int i)
d)
getMinRows(int i)
45.
Which of the following is used to rollback a JDBC transaction?
a)
rollback()
b)
rollforward()
c)
deleteTransaction()
d)
RemoveTransaction()
46.
Which of the following is not a JDBC connection isolation levels?
a)
TRANSACTION_NONE
b)
TRANSACTION_READ_COMMITTED
c)
TRANSACTION_REPEATABLE_READ
d)
TRANSACTION_NONREPEATABLE_READ
47.
Which method is used for retrieving streams of both ASCII and Unicode characters is new in the JDBC 2.0 core API?
a)
getCharacterStream
b)
getBinaryStream
c)
getAsciiStream
d)
getUnicodeStream
48.
Which method Drops all changes made since the previous commit/rollback?
a)
public void rollback()
b)
public void commit()
c)
public void close()
d)
public Statement createStatement()
49.
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)
50.
Which Indicates a result set that cannot be updated programmatically in concurrency?
a)
CONCUR_UPDATABLE
b)
CONCUR_READ_ONLY
c)
All of the above
d)
None of the above
51.
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
52.
Which result set generally does not show changes to the underlying database that are made while it is open. The membership, order, and column values of rows are typically fixed when the result set is created?
a)
TYPE_FORWARD_ONLY
b)
TYPE_SCROLL_INSENSITIVE
c)
TYPE_SCROLL_SENSITIVE
d)
ALL MENTIONED ABOVE
53.
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
54.
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
55.
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
56.

Which class or interface contains the transaction control methods setAutoCommit(),commit(), and rollback()?

a)

Statement

b)

Connection

c)

ResultSet

d)

none of the above

57.

Which character is used to represent an input parameter in CallableStatement?

a)

%-Percentage symbol

b)

#-hash

c)

?-Question Mark

d)

*-star

58.

When the message “No Suitable Driver” occurs ?

a)

When the type 4 driver is used?

b)

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

c)

When the JDBC database URL passed is not constructed properly

d)

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

59.

What does setAutoCommit(false) do?

a)

commits transaction after each query

b)

explicitly commits transaction

c)

does not commit transaction automatically after each query

d)

never commits transaction

60.

For inserting data into database Which Interface is used in JDBC Program?

a)

Statement

b)

PreparedStatement

c)

CallableStatement

d)

ParameterisedStatement

61.

Write the statement for establishing data base Connection in JDBC.

(a)  

62.

Which jar file should be set in the classpath for loading jdbc driver?

a)

odbc.jar

b)

ojdbc14.jar

c)

ojdbc23.jar

d)

jdbco20.jar

63.

Write a JDBC Program to retrieve the Student data from Student Table?

4 lines
64.

What are the methods in Statement Interface?

a)

public ResultSet executeQuery(String sql): is used to execute SELECT query. It returns the object of ResultSet.

b)

public int executeUpdate(String sql): is used to execute specified query, it may be create, drop, insert, update, delete etc.

c)

public boolean execute(String sql): is used to execute queries that may return multiple results.

d)

public int[] executeBatch(): is used to execute batch of commands.

65.

This method is for retrieving a String Value(SQL type VARCHAR) and assigning to String Object.

a)

getVarchar()

b)

getString()

c)

getObject()

d)

getInt()

66.

What are the Interfaces available in JDBC?

a)

Connection interface

b)

PreparedStatement interface

c)

ResultSet interface

d)

RowSet interface

67.

What is return type of executeUpdate() method ?

a)

int

b)

String

c)

Date

d)

ResultSet