Question: Consider the following function. public static void int getMaxInList (ArrayList list) { int max = 0; for(int i=0;i max) max = list.get(i); } return max;

 Consider the following function. public static void int getMaxInList (ArrayList list)

Consider the following function. public static void int getMaxInList (ArrayList list) { int max = 0; for(int i=0;i max) max = list.get(i); } return max; } Unit testing focuses on objects and functions such as this one. We can use this function if we want to find the maximum value in a list, however, there are cases where this function could fail. Give one case where it could fail. Write the list that is sent to the function as parameter "list," the value the function should have returned, what this function returns, and explain how the code could be improved to make it more robust

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!