CJCoding With Joseph
15per day
← Back to Question List

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

Topics:
Java Quiz #9

Count Zeros Method

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}