wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Java Quiz-2

Total questions: 15

Worksheet time: 18mins

Name
Class
Date
1.

What is the output of the following code?

a)

40, 30

b)

40, 40

c)

30, 40

d)

30, 30

2.

What is the output of the following code?

a)

15, 25

b)

15, 15

c)

25, 15

d)

25, 25

3.

What is the output of the following code?

a)

12.0, 12.0

b)

15.0, 12

c)

Compile Error

d)

15.0, 15.0

4.

Which one will NOT compile?

a)

byte b1; byte b2;

b)

int K, int L;

c)

short s1, s2, s3 = 5;

d)

long L1 = 4, L2, L3 = 7;

5.

If one value is int and the other is decimal, java will automatically promote int to the decimal point value's data type

a)

True

b)

False

6.

What will be the data type for x / y?

a)

short

b)

byte

c)

int

d)

long

7.

What is the data type of x / y * z?

a)

long

b)

double

c)

float

d)

short

8.

If the operator is placed after the value (n++), this case first original value will be used before the increase

a)

True

b)

False

9.

What is the output of the given code?

a)

2

b)

3

c)

4

d)

5

10.

What is the output of the given code?

a)

-4

b)

6

c)

-6

d)

4

11.

What is the output of the given code?

a)

1

b)

0

c)

Compile Time Error

d)

Null Pointer error

12.

What is the output of the given code?

a)

1

b)

5

c)

4

d)

Compile-Time Error

13.

Which expression can be used to test if String s is not equal to String t?

a)

s != t

b)

s.!equals(t)

c)

!s.equals(t)

d)

none of the above

14.

We use == sign to compare

a)

Primitives

b)

String (object)

15.

The string is one of the primitive data types in java.

a)

True

b)

False