Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Java Screening Test

Total questions: 40

Worksheet time: 36mins

Name
Class
Date
1.

Predict the output.

a)

[A, B, C]

b)

[1, 2, 3]

c)

{A=1, B=2, C=3}

d)

[A=1, B=2, C=3]

2.

Can I store duplicate values in a Map?

a)

Yes

b)

No

3.

Which of these packages contain classes and interfaces used for input & output operations of a program?

a)

java.lang

b)

java.io

c)

java.util

d)

java.stream

4.

Which of the followings are predefined streams in Java?

a)

System.in

b)

System.out

c)

System.err

d)

All the above

5.

What is the return type of readObject() method?

a)

void

b)

boolean

c)

String

d)

Object

6.

Predict the output.

a)

Java World World

b)

JavaJava World

c)

Java World Java World

d)

Compile Time Error

7.

Predict the output.

a)

abcdefabcDEF

b)

abcabcDEFDEF

c)

abcdefabcdef

d)

None of the above

8.

Which of the following is mutable object in Java?

a)

String

b)

StringBuffer

c)

Both A & B

d)

None of the above

9.

What is the return type of charAt() method in String Class?

a)

char

b)

int

c)

byte

d)

boolean

10.

What is the return type of split() method of String class?

a)

String

b)

Array

c)

String[]

d)

Object[]

11.

How to ensure only one thread has access to the shared object at a given point in time with multiple threads?

a)

synchronized blocks in thread class

synchronized method in thread class

b)

synchronized blocks in thread class

synchronized method in shared object class

c)

synchronized blocks in shared object class

synchronized method in thread class

d)

synchronized blocks in shared object class

synchronized method in shared object class

12.

Predict the output

a)

[3, 5]

b)

[3, 2]

c)

[3, 2, 5]

d)

[3, 5, 2]

13.

What will be the output of following program?

a)

alpha beta a b

b)

beta alpha b b

c)

alpha beta b b

d)

beta alpha a b

14.

Which of the following is index based collection?

a)

List

b)

Set

c)

SortedSet

d)

Map

15.

Which of the following is the method to add key and value pair in a Map collection?

a)

add()

b)

put()

c)

save()

d)

insert()

16.

What is the return type of hasNext() method of

an iterator interface?

a)

int

b)

boolean

c)

Object

d)

void

17.

An application module has to simulate train ticketing system to handle confirmed tickets, general Waiting List, Tatkal Waiting List, RAC etc

a)

ArrayList

b)

HashMap

c)

TreeMap

d)

PriorityQueue

18.

Fill the Code:

Map<Integer,String> map=new HashMap<Integer,String>();

map.put(1,"One");

map.put(4,"Four");

map.put(2,"Two"); Set<Map.Entry<Integer,String>> set=map.______________

a)

iterator()

b)

setEntry()

c)

enterySet()

d)

enteries()

19.

Which of the below is/are valid identifier with the main method?

a)

public

b)

private

c)

static

d)

this

20.

1. class main_class

2. {

3. public static void main(String args[])

4. {

5. int y = 10;

6. if (y == 10)

7. {

8. int y = 11;

9. System.out.println(y);

10. }

11. }

12. }

a)

Compilation error

b)

10

c)

11

d)

Run time error

21.

class KIET_Test {

int x;

}

class Main {

public static void main(String args[]) {

KIET_Test t = new KIET_Test();

System.out.println(t.x);

}

}

a)

garbage value

b)

0

c)

compiler error

d)

runtime error

22.

What is the output of the following program?

a)

"ABC"

b)

"ACB"

c)

"BAC"

d)

"CBA"

23.

What is the output of the following code snippet?

a)

apple, banana, cherry


b)

cherry, banana, apple

c)

banana, apple, cherry

d)

apple, cherry, banana

24.

What will be the output of following program?

a)

45

b)

18

c)

56

d)

30

25.

What will be the output of following program?

a)

HELLO WORLD JAVA

b)

hello world java

c)

HELLO WORLD

d)

HELLOWORLD

26.

What will be the output of following program?

a)

Derived

Derived

Base

b)

Base

Base

Derived

c)

Derived

Bae

Derived

d)

Base

Derived

Derived

27.

What will be the output of following program?

a)

0

b)

20

c)

compile time error

d)

Run time Error

28.

correct execution process in Java

a)

load->edit->compile->verify->execute

b)

edit->load->compile->execute->verify

c)

edit->compile->load->verify->execute

d)

verify->edit->compile->load->execute

29.

What is the extension of compiled java classes?

a)

.class

b)

.js

c)

.txt

d)

.java

30.

JVM is _____

a)

code dependent

b)

code independent

c)

platform dependent

d)

platform independent

31.

Which component is used to compile, debug and execute java program?

a)

JVM

b)

JDK

c)

JIT

d)

JRE

32.

Which kind of loop would be used?


I need a program that will keep letting me add a monthly payment for 12 months.

a)

FOR Loop

b)

WHILE Loop

33.

Which kind of loop would be used?


I need a guessing game program that will let me keep guessing until I get the right answer.

a)

FOR Loop

b)

WHILE Loop

34.

Which kind of loop would be used?


I need a program that will keep letting me add money to a piggy bank until I get to $100.

a)

FOR Loop

b)

WHILE Loop

35.
Which of the following loops prints "Welcome to Java" 10 times?
a)
A:
for (int count = 1; count <= 10; count++) {
 System.out.println("Welcome to Java");
b)
for (int count = 2; count < 10; count++) {
 System.out.println("Welcome to Java");
}
c)
for (int count = 1; count < 10; count++) {
 System.out.println("Welcome to Java");
}
d)
for (int count = 0; count <= 10; count++) {
 System.out.println("Welcome to Java");
}
36.
Which two statements are used to implement iteration?
a)
IF and WHILE
b)
ELSE and WHILE
c)
FOR and WHILE
d)
IF and ELSE
37.

FOR loops are

a)

loops which run an unknown number of times

b)

loops which run for a specific number of times

c)

the same as if statements

d)

not part of programming

38.

How many times does this print a * ?

a)

4

b)

5

c)

6

d)

7

39.
A collection of data items, all of the same type, in which each item's position is uniquely designated by an integer.
a)
array
b)
String
c)
char
d)
Integer
e)
algebra
40.

Which of the following is/are advantages of packages?

a)

Packages avoid name clashes

b)

Classes, even though they are visible outside their package, can have fields visible to packages only

c)

We can have hidden classes that are used by the packages, but not visible outside.

d)

All of the above