This is a JAVA question. Conside the following instance variable and method. pri
ID: 3836691 • Letter: T
Question
This is a JAVA question.
Conside the following instance variable and method.
private int [] numbers;
public int mystery(int num)
{ for (int k = numbers.length -1; k>= 0; k--)
{if (numbers[k] < num) return k;
} return -1;}
Which of the following best describes the contents of numbers 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 number.length - 1 are less than n
c) all values in positions m+1 through numbers.length - 1 are greater than or equal to n
d) The smaller value is at position m
e) The larger value that is smaller than n is at position m
Explanation / Answer
int m = mystery(n);
Ans: c) all values in positions m+1 through numbers.length - 1 are greater than or equal to n
private int [] numbers;
public int mystery(int num)
{
for (int k = numbers.length -1; k>= 0; k--)
{
if (numbers[k] < num)
return k;
}
return -1;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.