?

AP® Computer Science A

Free Version

Upgrade subject to access all content

Easy

Array Count: Determining Number of Even Numbers

APCSA-NLVG4Y

Consider the following.

public static int countEvensI(int[ ] nums)
{
     int count=0;

     for (int i=0; i<nums.length; i++)
     {
           _________________________ // fill in code here
     }
     return count;
}   

Which of the following can be used to replace ________//fill in code here so that countEvensI(int[ ] nums) will determine the number of even numbers in the array?

A
count++;
B
if( nums[i]/2 == 0 )
     count=count+1;
C
if( nums[i]%2 == 0 )
     count+=1;
D
if( i/2 == 0 )
     count++;
E
if( i%2 == 0 )
     count+=1;