Question: Consider the following Java function for computing the maximum value in an array: 1. static int maxVal(int [] arr) { 2. int i=arr. length 1;

 Consider the following Java function for computing the maximum value in
an array: 1. static int maxVal(int [] arr) \{ 2. int i=arr.

Consider the following Java function for computing the maximum value in an array: 1. static int maxVal(int [] arr) \{ 2. int i=arr. length 1; 3. int result =arr[i]; 4. while (i>=0){ 5. if (arr[i]> result ){ 6. result =arr[i] 6'. result =arr[i+1] 7. 3 8. i 9. } 10. return result; \} Line 6' shows a mutant of line 6 (i.e., in the mutated program, line 6 is replaced with line 6'). Answer the following questions. When you are asked to give a test input, give a value for the input array arr, written using square brackets, e.g., [0,1,2]. Note that the value null and the empty array [] are not allowed as a solution for any of the questions below. (a) (5 points) If possible, give a test input and an expected return value that strongly kills the mutant. (Assume that the test function asserts that the value returned from maxVal () is the expected value.) Otherwise, state that no such input and return value exists. 6. resut =arr[i];6resut=arr[i+1]; testinput=[10,1,x][3,5,1]expectedretwen=5. (b) (5 points) If possible, give a test input that does not reach the mutant. Otherwise, state that no such input exists. (c) (5 points) If possible, find a test input that satisfies reachability but not infection for the mutant. Otherwise, state that no such input exists. For Mutation testing , infection is ats reached after reachability is satisfied. testinput000,00[3,5,1] (d) ( 5 points) If possible, find a test input that satisfies infection but not propagation for the mutant. Otherwise, state that no such input exists

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!