Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

PJP Apr 23

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

Which one of the following packages contain the JDBC classes?

a)

java.util

b)

java.sql

c)

java.lang

d)

java.awt

2.

What type of object is returned when we invoke the getMetaData method on the Connection object?

a)

ConnectionMetaData

b)

DatabaseMetaData

c)

StatementMetaData

d)

ResultSetMetaData

3.

In which one of the following interfaces, the query is compiled only once?

a)

PreparedStatement

b)

Statement

4.

How do we get the count of the total number of records updated by executing the below query? Lets store the count in a variable "num".


PreparedStatement stmt=con.prepareStatement("update emp set name=? where id=?");

stmt.setString(1,"Sonoo");

stmt.setInt(2,101);

a)

int num = executeUpdate();

b)

int num = stmt.execute();

c)

int num = stmt.executeUpdate();

d)

int num = stmt.executeQuery();

5.

Assumption:

class Test1 is under com.test package

class Test2 is under com.test.pack1 package


And if you are importing as,

import com.test.*;

Which all classes and packages will be imported?

a)

Test1, pack1 and Test2

b)

Test1 and Test2

c)

Test1 and pack1

d)

Test1

6.

Which of the following methods is valid for HashMap class> Select all the correct methods.

a)

put

b)

add

c)

addAll

d)

get

7.

Which one of the following methods is valid for TreeSet class?

a)

get

b)

put

c)

first

d)

getAfter

8.

Predict the output of the given code:

a)

[1,7,5,4,20]

b)

[1,4,5,7,20]

c)

[20,7,5,4,1]

d)

[1,5,4,7,20]

9.

Which one of the following objects is used to store Key Value pair?

a)

List

b)

Set

c)

TreeMap

d)

SortedSet

10.

What is the return type of add method in Collection interface?

a)

int

b)

double

c)

char

d)

boolean