Question: 3. Below are four faulty programs. Each includes a test case that results in fail- ure. Answer the following questions about each program public static

 3. Below are four faulty programs. Each includes a test casethat results in fail- ure. Answer the following questions about each program

3. Below are four faulty programs. Each includes a test case that results in fail- ure. Answer the following questions about each program public static int lastzero (int[] x f public int findLast (int[] x, int y) Effects: If x null throw NullPointerException Effects: if x null throw NullPointerException else return the index of the last element else return the index of the LAST 0 in x. in x that equals y Return -1 if 0 does not occur in x If no such element exists, return -1 for (int i x length-1; i 0; i--) for (int i 0; i x.length; i++) if (x[i] 2- y) if (x 0) return i return i -1 return -1; return. test: x 2, 3, 51; y 2 test: x 10, 1, 01 Expected 0 Expected 2 public int countPositive (int[J x) public static int oddorPos(int[] x) H /Effects: If x null throw NullPointerException Effects: if x null throw NullPointerException. else return the number of else return the number of elements in x that positive elements in x are either odd or positive (or both) int count 0 int count 0 for (int i 0; i

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!