wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Java_Quiz_Part_2

Total questions: 12

Worksheet time: 11mins

Name
Class
Date
1.

Which of these are selection statements in Java?

a)

if()

b)

for()

c)

break

d)

else

2.

What will be the output of the following Java program?

a)

1

b)

2

c)

3

d)

4

3.

What will be the output of the following Java program?


a)

5

b)

6

c)

14

d)

compilation error

4.

What will be the output of the following Java program?

a)

1 3 5 7

b)

2 4 6 8

c)

1 3 5 7 9

d)

1 2 3 4 5 6 7 8 9

5.

Which of these keywords can be used to prevent inheritance of a class?

a)

super

b)

constant

c)

class

d)

final

6.

Which of the following is a type of polymorphism in Java?

a)

Compile time polymorphism

b)

Execution time polymorphism

c)

Multiple polymorphism

d)

Multilevel polymorphism

7.

What will be the output of the following Java program?

a)

5 6 5 6

b)

5 6 5

c)

Runtime error

d)

Compilation error

8.


Find the output of the following code.

int Integer = 24;

char String = ‘I’;

System.out.print(Integer);

System.out.print(String);

a)

Compile Error

b)

throws exception

c)

l

d)

24 l

9.

What will be the output of the following program?

a)
  1. 15 times ***

b)
  1. 15 times +++++

c)
  1. 8 times *** and 7 times +++++

d)
  1. Both will print only once

10.

What will be the output of the following Java program?


a)

1

b)

2

c)

Runtime error

d)

Garbage value

11.

What will be the output of the following Java program?


a)

0

b)

1

c)

Runtime error

d)

classname@hashcode in hexadecimal form

12.

What will be the output of the following Java code?


a)

5

b)

6

c)

7

d)

8