int[] a = {2, 5, 2, 7, 2, 8};
int count = 0;
for (int x : a) {
if (x == 2) count++;
}What is count?
- A
4
- B
2
- Ccheck_circle
3
- D
1
Explanation
The value 2 appears at indices 0, 2, and 4, so count is 3.
AP Computer Science A· difficulty 2/5
int[] a = {2, 5, 2, 7, 2, 8};
int count = 0;
for (int x : a) {
if (x == 2) count++;
}What is count?
4
2
3
1
Explanation
The value 2 appears at indices 0, 2, and 4, so count is 3.
Want 10 more like this — adaptive to your weak spots?