Choosing how to earn college credit? CLEP vs AP guide
| preferred AP College board partner for AP classes
AP Computer Science A/Unit 4: Data Collections
Start Practice TestPractice Test
About Exam
easy

Counting Elements in an Array

Mark
< Prev
Next >

The following code segment is intended to count the number of integers in the array nums that are greater than 50. Which statement should replace /* missing code */ so that the code segment works as intended?

int count = 0;
int[] nums = {42, 67, 55, 33, 99, 78};
for (int num : nums) {
    /* missing code */
}
System.out.println(count);
A

if (num > 50) count += 1;

B

if (num < 50) ++count;

C

if (num > 50) count += 1 + count;

D

if (num >= 50) count–;

Hint
Did You Know?
Explain Why
Explain All Answers
Check Answer
Show Correct Answer
Report Question

Question Leaderboard

Not enough data yet to show leaderboard.

No comments yet. Be the first to comment!

AI Tutor

How can I help?

APFIVE © 2020.
Email: apfive@apfive.org|Instagram: @_apfive_|Privacy Policy|