Question: Below is a faulty Java program, which includes a test case that results in a failure. The if-statement needs to take account of negative values.

Below is a faulty Java program, which includes a test case that results in a failure. The if-statement needs to take account of negative values. A possible fix is: if (x[i]%2 != 0) Answer the following questions for this program. (a) If possible, identify a test case that does not execute the fault. (b) If possible, identify a test case that executes the fault, but does not result in an error state. (c) If possible, identify a test case that results in an error, but not a failure. (d) For the test case (x = [-10,-9, 0, 99, 100), expected output: 2), identify the first error state. Describe the complete state. public static int odd(int[] x) { // Effects: if x==null throw NullPointerException, Il else return the number of elements in x that are odd int count = 0; for (int i =0; i
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
