Question: Consider the following method which accesses the properly declared and initialized int array arr and is intended to return the maximum value in arr.

Consider the following method which accesses the properly declared and initialized int array arr and is intended to return the maximum value in arr. public int findMax() { int maxVal = 0; for (int i = 0; i < arr.length; i++) { if (arr[i] > maxVal) } { maxVal = arr[i]; } return maxVal; In which of the following situations, if any, does findMax() not work as intended? If the largest value in arr is negative b. If the largest value in arr is zero c. If the largest value in arr occurs only once and is at arr[0] d. If the largest value in arr occurs only once and is at arr[arr.length - 1] e. None; findMax() works as intended for all int arrays
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
