<分区>
我正在准备下周的考试,我决定在网上找一些考试题以便更好地准备。
我遇到了这个问题,答案是c。但我真的很想知道如何或逐步回答这样的问题。我卡住的部分是试图从逻辑上理解 int m = mystery(n);
一个数字如何等于一个方法?每当我遇到这样的问题时,我应该先分割一下吗?
private int[] myStuff;
/** Precondition : myStuff contains int values in no particular order.
/*/
public int mystery(int num)
{
for (int k = myStuff.length - 1; k >= 0; k--)
{
if (myStuff[k] < num)
{
return k;
}
}
return -1;
}
Which of the following best describes the contents of myStuff after the
following statement has been executed?
int m = mystery(n);
(a) All values in positions 0 through m are less than n.
(b) All values in positions m+1 through myStuff.length-1 are
less than n.
(c) All values in positions m+1 through myStuff.length-1 are
greater than or equal to n.
(d) The smallest value is at position m.
(e) The largest value that is smaller than n is at position m.