Question 6
Back to Exercise
What is the output of the following Java program?
import java.util.ArrayList;
import java.util.List;
public class Main {
static final List<Integer> SCORES = new ArrayList<>();
public static void main(String[] args) {
SCORES.add(90);
SCORES.add(75);
SCORES.remove(Integer.valueOf(90));
SCORES.add(0, 60);
System.out.println(SCORES + " " + SCORES.size());
}
}
- A [60, 75] 2 Correct
- B [] 0
- C Compilation error
- D [90, 75, 60] 3
Correct Answer: Option A
final stops reassigning SCORES, not modifying the list it refers to.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!