CJCoding With Joseph
15free / daySign inCreate account
Back to Multiple Choice Quiz

Select topics to narrow your question pool, then enable Random to jump to a random question matching your filters.

Topics

Count Zeros Method

Java quiz · Question 9
mediumArrays

What does this method return when called with countZeros({1, 0, 2, 0, 3})?

Code

1public static int countZeros(int[] arr) {
2 int count = 0;
3 for (int num : arr) {
4 if (num == 0) {
5 count++;
6 }
7 }
8 return count;
9}