Solved

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

Question 29

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

Unlock this Answer For Free Now!

View this answer and more for free by performing one of the following actions

qr-code

Scan the QR code to install the App and get 2 free unlocks

upload documents

Unlock quizzes for free by uploading documents