wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

CodeHS 2.5 Casting

Total questions: 10

Worksheet time: 9mins

Name
Class
Date
1.

What is the value of average?

(a)  

2.

If you add 0.5 to a double and then cast it to an int, what have you just done?

a)

Rounded to the nearest whole number

b)

Created an error

c)

The same thing as if you'd skipped the adding part

d)

The same thing as if you'd skipped the casting part

3.

Choose the correct option:

int foo = ​ (a)   867.5309;

Choose from the below words
(int)
(double)
[int]
[double]
{int}
{double}
4.

How do you cast an int called foo into a double?

a)

You don't really have to

b)

(double)foo

c)

(int)foo

d)

double nuFoo = foo

5.

What is the resulting value of

(int)23.5

a)

24

b)

23

c)

23.5

d)

trick question, it's an error

6.

What do we call data given by the user?

(a)  

7.

int gir = 23 / 5;


What is stored in gir?

(a)  

8.

How do we store data given by a user and taken by a method?

a)

in a String

b)

in a variable

c)

in a class

d)

trick question: the method stores it for us

9.

What is the name (just the name) of the method used to get a double from a user?

(a)  

10.

What is the name (just the name) of the method used to get an integer from a user?

(a)