Font size
WorksheetsCodeHS 2.5 Casting
Total questions: 10
Worksheet time: 9mins
What is the value of average?
(a)
If you add 0.5 to a double and then cast it to an int, what have you just done?
Rounded to the nearest whole number
Created an error
The same thing as if you'd skipped the adding part
The same thing as if you'd skipped the casting part
Choose the correct option:
int foo = (a) 867.5309;
How do you cast an int called foo into a double?
You don't really have to
(double)foo
(int)foo
double nuFoo = foo
What is the resulting value of
(int)23.5
24
23
23.5
trick question, it's an error
What do we call data given by the user?
(a)
int gir = 23 / 5;
What is stored in gir?
(a)
How do we store data given by a user and taken by a method?
in a String
in a variable
in a class
trick question: the method stores it for us
What is the name (just the name) of the method used to get a double from a user?
(a)
What is the name (just the name) of the method used to get an integer from a user?
(a)
