The following code for method minVal contains a logic error on a single line in the method body, on one of the four lines indicated by comments: public static int minVal(int[] y, int first, int last) { /* This method returns the value of the minimum element in the * subsection of the array "y", starting at position * "first" and ending at position "last". */ int bestSoFar = y[first]; for (int i=first+1; i<=last; i++) // line 1 { if ( y[i] < y[bestSoFar] ) // line 2 bestSoFar = y[i]; // line 3 } // for return bestSoFar; // line 4 } // method minVal Which one of the four lines indicated by the comments contains the logic error?单项选择题

A

2

B

1

C

3

D

4

登录即可查看完整答案

我们收录了全球超50000道真实原题与详细解析,现在登录,立即获得答案。

类似问题

更多留学生实用工具

加入我们,立即解锁 海量真题独家解析,让复习快人一步!