Complete the below Java code to count the number of instances the target value appears in the array.
public class CountTargetOccurrences {
public static int countOccurrences(int[] nums, int target) {
// Your code here
}
public static void main(String[] args) {
int[] arr = {1, 2, 3, 4, 5, 2, 2};
int target = 2;
System.out.println(countOccurrences(arr, target)); // Output: 3 }}
A) for(int num : nums) { if(num == target) count++; }
B) if(nums[i] == target) count++;
C) count = Arrays.stream(nums).filter(num -> num == target).count();
D) if(nums.get(i) == target) count++;