Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Casting in Java

Total questions: 15

Worksheet time: 9mins

Name
Class
Date
1.

What is the value stored in x?

double x = (int) (1.8 * 2.0)

a)

3.0

b)

3

c)

3.6

d)

Error

2.

What is the value stored in x?

double x = (int) 1.8 * 2.0

a)

3.0

b)

2.0

c)

3.6

d)

Error

3.

What is the value stored in x?

int x = 1.8 * 2.0

a)

3

b)

2

c)

3.6

d)

Error

4.

What is the value of:

(int) (1 + 1 + 1 + 1 + 1.0 + 1 + 1 / 8)

a)

1

b)

0

c)

0.875

5.
For Modular Arithmetic what value is the most important?
a)
The Modulo
b)
The Given Number
c)
The Remainder
d)
The Divisor
6.

5%2

a)

3

b)

5

c)

2

d)

1

7.

6%12

a)

0

b)

2

c)

6

d)

1

8.

42%6

a)

7

b)

1

c)

0

d)

2

9.

81%2

a)

0

b)

3

c)

1

d)

9

10.

55%10

a)

0

b)

5

c)

50

d)

5.5

11.
The name of Ricky Bobby’s best friend in Talladega Nights?
a)
Dale Earnhardt, Jr
b)
Cal Naughton, Jr.
c)
Richard Petty
d)
Jeff Gordon
12.

The Statue of Liberty holds her torch in what hand?

a)

Right

b)

Left

13.

double x = 2.0;

int y = 3;

int z = 4;

x=( (double) y + z) /2

translates to:

a)

(3.0 + 4) /2 = 3.0

b)

(3.0 + 4) /2 = 3.5

c)

(3.0 + 4.0)/2 = 3.5

d)

7.0/2 =3.5

14.

double x;

x = (double)(11/2);

What is the value stored in x?

a)

4.0

b)

4.5

15.

Which of these is valid?

line 1 int x = 2/2;

line 2 double y = 2;

a)

line 1

b)

line 2

c)

neither of these

d)

both of these