0%
0 / 15 answered
Casting and Range of Variables Practice Test
•15 QuestionsQuestion
1 / 15
Q1
A physics simulation sends pixels to a graphics API:
class MotionRenderer {
public static int toPixels(double meters) {
double pixels = meters * 100.0;
return (int) pixels; // truncation for API compatibility
}
}
Based on the code above, what will be the result of casting the variable pixels from double to int?
A physics simulation sends pixels to a graphics API:
class MotionRenderer {
public static int toPixels(double meters) {
double pixels = meters * 100.0;
return (int) pixels; // truncation for API compatibility
}
}
Based on the code above, what will be the result of casting the variable pixels from double to int?