Solved

The Method Int GetPosition(int Array[],int X)is Designed to Return the Position

Question 27

Multiple Choice

The method int getPosition(int array[],int X) is designed to return the position of X within the array.If X is not in the array,the method may return either -1 or array.length.Which of the following is a correct implementation for this method?


A) int k = 0;
While (array[k] != X) {k ++};return k;
B) int k = 0;
While (k < array.length.{if (array[k] != X.return -1;else return k;}
C) int k = 0;
While (k < array.length && array[k] != X.{ k++;} return k;
D) int k = 0;
While (k < array.length && array[k] != X.{ k++;return k;}

Correct Answer:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions