0%
0 / 8 answered
Compound Assignment Operators Practice Test
•8 QuestionsQuestion
1 / 8
Q1
What is the final value of score after execution of the game score code below?
public class GameScoreTotal {
public static void main(String[] args) {
int score = 7; // starting score
/* Earn points for actions */
score += 9; // bonus points
score *= 3; // triple score
// Penalty for mistake
score -= 5; // subtract 5
// Convert to points per level (2 levels)
score /= 2; // integer division
// Keep only remainder when split into 4 teams
score %= 4; // remainder
System.out.println("Final score: " + score);
}
}
What is the final value of score after execution of the game score code below?
public class GameScoreTotal {
public static void main(String[] args) {
int score = 7; // starting score
/* Earn points for actions */
score += 9; // bonus points
score *= 3; // triple score
// Penalty for mistake
score -= 5; // subtract 5
// Convert to points per level (2 levels)
score /= 2; // integer division
// Keep only remainder when split into 4 teams
score %= 4; // remainder
System.out.println("Final score: " + score);
}
}