wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Java Programming Quiz

Total questions: 10

Worksheet time: 2mins

Name
Class
Date
1.

What is the output?

System.out.println((10 + 20) * 2);

a)

50

b)

60

c)

70

d)

80

2.

What is the result of 5 & 3?

a)

1

b)

2

c)

3

d)

5

3.

What will happen? int[] arr = new int[3]; arr[0] = 10; arr[3] = 20;

a)

arr[3] = 20 stored successfully

b)

Compile time error

c)

Runtime error (ArrayIndexOutOfBoundsException)

d)

Garbage value

4.

Which conversion is allowed implicitly?

a)

int → byte

b)

byte → int

c)

double → int

d)

long → short

5.

What is the output? char c = 'B'; int i = c; System.out.println(i);

a)

B

b)

66

c)

Error

d)

65

6.

What will be the output? float f = 5.5f; int i = (int) f; System.out.println(i);

a)

5

b)

5.5

c)

Error

d)

6

7.

What is the result of 10 | 4?

a)

6

b)

4

c)

10

d)

14

8.

What will happen? String str = null; System.out.println(str.length());

a)

0

b)

NullPointerException

c)

Compile time error

d)

Empty string

9.

What will be the result? boolean flag = true; System.out.println(!flag);

a)

false

b)

true

c)

Error

d)

Null

10.

What will happen? int[] numbers = new int[2]; numbers[2] = 15;

a)

Garbage value

b)

Compile time error

c)

Runtime error (ArrayIndexOutOfBoundsException)

d)

15 stored successfully