0%
0 / 15 answered
Casting and Range of Variables Practice Test
•15 QuestionsQuestion
1 / 15
Q1
In a game, bonuses are doubles but score is int:
class ScoreKeeper {
public static int applyBonus(int score, double bonus) {
int total = score + (int) bonus; // truncates decimals
return total;
}
}
Based on the code above, what will be the result of casting the variable bonus from double to int?
In a game, bonuses are doubles but score is int:
class ScoreKeeper {
public static int applyBonus(int score, double bonus) {
int total = score + (int) bonus; // truncates decimals
return total;
}
}
Based on the code above, what will be the result of casting the variable bonus from double to int?