OddOrPos
<source lang="java"> /**
* If x == null throw NullPointerException, else return the number of * elements in x that are either odd or positive (or both). */
public static int oddOrPos(int[] x) { int count = 0; for (int i = 0; i < x.length; i++) { if (x[i]% 2 == 1 || x[i] > 0) { count++; } } return count; } </source>
- Identify the fault for the test case {Input: x = [-3, -2, 0, 1, 4; Expected output = 3}.
- If possible, identify a test case that does not execute the fault.
- If possible, identify a test case that executes the fault, but does not result in an error state.
- If possible identify a test case that results in an error, but not a failure. Hint: Don’t forget about the program counter.
- For the given test case, identify the first error state. Be sure to describe the complete state.
- Fix the fault and verify that the given test now produces the expected output.