wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Java _TalentNext_2

Total questions: 85

Worksheet time: 44mins

Name
Class
Date
1.

JUnit is used for what type of software testing for the Java language?

a)

Functional Testing

b)

System Testing

c)

Unit Testing

d)

Integration Testing

2.

Which annotation implies that a method is a JUnit test case?

a)

@org.junit.Test

b)

@org.Test

c)

@testcase

d)

@junit

3.

JUnit test files are written in files with which file extension?

a)

.unit

b)

.java

c)

.test

d)

.junit

4.

Which methods cannot be tested by the JUnit test class?

a)

protected methods

b)

methods with void return type

c)

private methods

d)

public methods

5.

JUnit test methods must compulsorily return what value?

a)

void

b)

Object

c)

String

d)

int

6.

To use JUnit in a project we need to add which JAR files on our test classpath?

a)

java-junit.jar

b)

junit.jar and hamcrest-core.jar

c)

hamcrest-core.jar

d)

junit.jar

7.

Which of the following method of Assert class checks that a condition is false?

a)

void assert(boolean condition)

b)

void assertFalse(boolean condition)

c)

void assertCheck(boolean condition)

d)

void assertChecks(boolean condition)

8.

Which of the following class is used to bundle unit test cases and run them together?

a)

JUnitCore

b)

TestCase

c)

TestSuite

d)

TestResult

9.

Which of the following describes Testing correctly?

a)

Testing is the process of checking the functionality of the application whether it is working as per requirements.

b)

Testing is the testing of single entity (class or method).

c)

Both of the above.

d)

None of the above.

10.

Which of the following method of Assert class checks that a condition is true?

a)

void assert(boolean condition)

b)

void assertTrue(boolean condition)

c)

void assertCheck(boolean condition)

d)

void assertChecks(boolean condition)

11.

How many ways a thread can be created in Java multithreading?

a)

1

b)

2

c)

5

d)

10

12.

Which method is used to make main thread to wait for all child threads

a)

Join ()

b)

Sleep ()

c)

Wait ()

d)

Stop ()

13.

Which will contain the body of the thread in Java?

a)

Start()

b)

Run()

c)

Main()

d)

Execute()

14.

The life cycle of a thread in java is controlled by

a)

JRE

b)

JDK

c)

JVM

d)

None

15.

Which method is used to get current running thread object?

a)

runningThread()

b)

currentThread()

c)

runnableThread()

d)

None

16.

Synchronized static methods acquire lock on

a)

Class

b)

Object

c)

Interface

d)

None

17.

Thread priority in Java is?

a)

Integer

b)

Float

c)

Double

d)

Long

18.

In JAVA multi threading, a thread can be created by_______

a)

Extending class

b)

Implementing Runnable Interface

c)

both

d)

none

19.

Which statements is/are correct

a)

On calling Thread start ( ) method a new thread is created

b)

Thread start( ) method call run( ) method internally

c)

Thread run( ) method can also be called directly to create thread

d)

both a & b

20.

Q) What is maximum thread priority in Java

a)

10

b)

12

c)

5

d)

8

21.

Q) Number of threads in below java program is

public class ThreadExtended extends Thread {


public void run() {

System.out.println("\nThread is running now\n");

}


public static void main(String[] args) {


ThreadExtended threadE = new ThreadExtended();


threadE.start();

}

}

a)

0

b)

1

c)

2

d)

3

22.

Q) Execution of a java thread begins on which method call?

a)

Start ()

b)

Run ()

c)

Execute ()

d)

Launch ()

23.

Q) Which method is used to check if a thread is running?

a)

isAlive()

b)

run ()

c)

alive ()

d)

keepAlive()

24.

Q) Min and Max priority of a thread in Java multithreading are

a)

1, 10

b)

0,10

c)

0,255

d)

1,256

25.
What is sometimes also called a lightweight process?
a)
Thread
b)
Process
c)
JVM
26.
Which of these is not a Thread state?
a)
New
b)
Runnable
c)
sleep
d)
terminated
27.

___________distributing task across multiple computing cores

a)

data parallelism

b)

implicit threading

c)

task parallelism

d)

identifying task

28.

Execution of a java thread begins on which method call?

a)

Run ()

b)

Start ()

c)

Execute ()

d)

Launch ()

29.

Choose THREE(3) benefits of multithreaded processing

a)

scalability

b)

resource sharing

c)

privacy

d)

responsiveness

30.

Thread is _____________process that can run independently

a)

heavyweight

b)

lightweight

c)

compaction

d)

compression

31.

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

a)

Type-4

b)

Type-3

c)

Type-2

d)

Type-1

32.

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

a)

Type 1

b)

Type 2

c)

Type 3

d)

Type 4

33.

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

34.

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)

35.

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

36.

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

37.

Which method is used to perform DML statements in JDBC?

a)

execute()

b)

executeQuery()

c)

executeUpdate()

d)

executeResult()

38.

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

39.

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

a)

True

b)

False

40.

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)

41.

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

42.

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

43.

What is used to execute parameterized query?

a)

Statement interface

b)

PreparedStatement interface

c)

ResultSet interface

d)

None of the above

44.

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

45.

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

a)

rollback()

b)

rollforward()

c)

deleteTransaction()

d)

RemoveTransaction()

46.

Which method is used to perform DML statements in JDBC?

a)

execute()

b)

executeQuery()

c)

executeUpdate()

d)

executeResult()

47.

This method is used to extract data from result set

a)

next()

b)

getString()

48.

This provides the application-to-JDBC Manager connection

a)

JDBC Driver API

b)

JDBC API

49.

What is the body of a Thread

a)

Run

b)

Begin

c)

Execute

d)

Start

e)

Resume

50.
JDBC technology-based drivers generally fit into how many categories?
a)
4
b)
3
c)
2
d)
5
51.
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
d)
 java.rdb and javax.rdb
52.
The ................................ method executes a simple query and returns a single Result Set object.
a)
executeUpdate()
b)
executeQuery()
c)
execute()
d)
noexecute()
53.

Select DDL commands from among the options...

a)

SELECT

b)

ALTER

c)

DROP

d)

DELETE

54.

Choose the correct query

a)

SELECT * FROM EMP WHERE NAME=NULL

b)

SELECT * FROM EMP WHERE NAME IS NULL;

c)

SELECT FROM EMP WHERE NAME IS NULL;

d)

SELECT *FROM EMP WHERE NAME IS 'NULL';

55.

Which is the correct query to delete the rows of employees whose exp is less than 10.

a)

DELETE * FROM EMP WHERE EXP<10;

b)

DELETE FROM EMP;

c)

DELETE FROM EMP WHERE EXP<10;

d)

DELETE FROM EMP WHERE EXP>10;

56.

Atomicity, Consistency, Isolation, and Durability − commonly known as ........... properties

a)

AID

b)

ADIC

c)

ACID

d)

DBMS

57.

.......... is the process of organizing the data in the database.

a)

Schema

b)

Normalization

c)

Instance

d)

Transaction

58.

With SQL, how do you select all the records from a table named "Persons" where the value of the column "FirstName" starts with an "a"?

a)

SELECT * FROM Persons WHERE FirstName='a'

b)

SELECT * FROM Persons WHERE FirstName LIKE 'a%'

c)

SELECT * FROM Persons WHERE FirstName='%a%'

d)

SELECT * FROM Persons WHERE FirstName LIKE '%a'

59.

With SQL, how do you select all the records from a table named "Persons" where the "FirstName" is "Peter" and the "LastName" is "Jackson"?

a)

SELECT * FROM Persons WHERE FirstName='Peter' AND LastName='Jackson'

b)

SELECT * FROM Persons WHERE FirstName<>'Peter' AND LastName<>'Jackson'

c)

SELECT FirstName='Peter', LastName='Jackson' FROM Persons

60.

With SQL, how can you insert a new record into the "Persons" table?

a)

INSERT ('Jimmy', 'Jackson') INTO Persons

b)

INSERT VALUES ('Jimmy', 'Jackson') INTO Persons

c)

INSERT INTO Persons VALUES ('Jimmy', 'Jackson')

61.

How can you change "Hansen" into "Nilsen" in the "LastName" column in the Persons table?

a)

MODIFY Persons SET LastName='Hansen' INTO LastName='Nilsen

b)

MODIFY Persons SET LastName='Nilsen' WHERE LastName='Hansen'

c)

UPDATE Persons SET LastName='Hansen' INTO LastName='Nilsen'

d)

UPDATE Persons SET LastName='Nilsen' WHERE LastName='Hansen'

62.

With SQL, how can you return the number of records in the "Persons" table?

Next ❯

a)

SELECT NO(*) FROM Persons

b)

SELECT COLUMNS(*) FROM Persons

c)

SELECT COUNT(*) FROM Persons

d)

SELECT LEN(*) FROM Persons

63.

The NOT NULL constraint enforces a column to not accept empty values.


Next ❯

a)

TRUE

b)

FALSE

64.

Which operator is used to search for a specified pattern in a column?

a)

GET

b)

FROM

c)

LIKE

65.

CREATE TABLE employee (id INTEGER,name VARCHAR(20),salary NOT NULL);

INSERT INTO employee VALUES (1005,Rach,0);

INSERT INTO employee VALUES (1007,Ross, );

INSERT INTO employee VALUES (1002,Joey,335);


Some of these insert statements will produce an error. Identify the statement.

a)

Insert into employee values (1005,Rach,0);

b)

Insert into employee values (1002,Joey,335);

c)

Insert into employee values (1007,Ross, );

d)

None of the mentioned

66.

In the given query which of the keyword has to be inserted?

INSERT INTO employee _____ (1002,Joey,2000);

a)

Table

b)

Values

c)

Relation

d)

Field

67.

SELECT * FROM employee WHERE salary>10000 AND dept_id=101;

Which of the following fields are displayed as output?

a)

Salary, dept_id

b)

Employee

c)

Salary

d)

All the field of employee relation

68.

Consider the following code snippet: what will be the output?

DECLARE

a number(2) ;

BEGIN

FOR a IN REVERSE 10 .. 20 LOOP

END LOOP;

dbms_output.put_line(a);

END;

a)

20

b)

29

c)

10

d)

30

69.

What will be the output of the following code snippet?

a)

21

b)

21, 10

c)

10

d)

error

70.

What is wrong in the following code snippet?

DECLARE

x number := 1;

BEGIN

LOOP

dbms_output.put_line(x);

x := x + 1;

IF x > 10 THEN

exit;

END IF;

dbms_output.put_line('After Exit x is: ' || x);

END;

a)

Code is correct.

b)

IF statement is not required.

c)

END LOOP is missing.

d)

Every IF must have ELSE statement.

71.

_____cursor is declared by ORACLE for each UPDATE, DELETE and INSERT SQL commands.

a)

Internal

b)

External

c)

Implicit

d)

Explicit

72.

Which of the below options is correct to load the Oracle JDBC driver?

a)

Class.forName("oracle.jdbc.driver.OracleDBDriver");

b)

Class.forName("Oracle.Jdbc.Driver.OracleDriver");

c)

Class.forName("jdbc.oracle.driver.OracleDriver");

d)

Class.forName("oracle.jdbc.driver.OracleDriver");

73.

Which of the below queries is correct to display the Employee details such as empno, ename, sal from emp table whose empno contains 77 in it?

a)

select empno,ename,sal from emp where empno is 77;

b)

select empno,ename,sal from emp where empno like '_77%';

c)

select empno,ename,sal from emp where empno like '%77%';

d)

select empno,ename,sal from emp where empno like '_77_';

74.

Which refers to connecting entities of different types when identifiers are different?

a)

HAS-A relationships

b)

IS-A relationships

c)

Binary relationship

d)

None

75.

Relationships among entities of a single class are called_______?

a)

IS-A relationships

b)

Recursive relationships

c)

HAS-A relationships

d)

None

76.

An attribute which consists of a group of attributes is called ______?

a)

Composite attributes

b)

Multi-valued attributes

c)

Composite identifiers

d)

Identifiers

77.

An SQL query to delete a data from the table and memory while keeping the structure of the table intact?

a)

a)TRUNCATE TABLE table_name;

b)

b)DELETE FROM TABLE table_name;

c)

c)DROP TABLE table_name;

d)

d)DROP FROM TABLE table_name;

78.

Which of the following are the five built-in aggerate functions provided by SQL?

a)

a)SUM, AVG, MIN, MAX, MULT

b)

b)COUNT, SUM, AVG, MAX, MIN

c)

c)SUM, AVG, MULT, DIV, MIN

d)

d)SUM, AVG, MIN, MAX, NAME

79.

Table Employee has 10 records. It has a non-NULL SALARY column which is also UNIQUE.

So, What the below SQL statement will return: SELECT COUNT(*) FROM Employee WHERE SALARY > ANY (SELECT SALARY FROM EMPLOYEE);

a)

A.10

b)

B.9

c)

C.5

d)

D.0

80.

The SQL statement - SELECT SUBSTR('abcdefghij', INSTR('123321234', '2', 3, 2), 2) FROM DUAL; Prints

a)

A.gh

b)

B. 23

c)

C.bc

d)

D. ab

81.

To define what columns should be displayed in an SQL SELECT statement:

a)

A. use FROM to name the source table(s) and list the columns to be shown after SELECT.

b)

B. use USING to name the source table(s) and list the columns to be shown after SELECT.

c)

C. use SELECT to name the source table(s) and list the columns to be shown after USING.

d)

D. use USING to name the source table(s) and list the columns to be shown after WHERE.

82.

Find the SQL statement below that is equal to the following: SELECT NAME FROM CUSTOMER WHERE STATE = 'VA';

a)

A. SELECT NAME IN CUSTOMER WHERE STATE IN ('VA');

b)

B. SELECT NAME IN CUSTOMER WHERE STATE = 'VA';

c)

C. SELECT NAME IN CUSTOMER WHERE STATE = 'V';

d)

D. SELECT NAME FROM CUSTOMER WHERE STATE IN ('VA');

83.

SQL query and modification commands make up a(n) ________ .

a)

A. DDL

b)

B. DML

c)

C. HTML

d)

D. XML

84.

1. Which of the following Statement will cancel the SAVEPOINTS

a)

iNSERT

b)

UPDATE

c)

DELETE

d)

COMMIT

85.

The union of primary keys of the related entity sets becomes a -------------------------- of the relation ?

a)

Super Key

b)

Candidate key

c)

Foreign key

d)

Primary key