Limited access

Upgrade to access all content for this subject

Consider the following code segment.

/**
* Randomly choose digit from the array.
* @param digits array of digits
* @return random digit
* Precondition: array elements can only be integers 0-9
* Precondition: digits is sorted in descending order
* Precondition: digits has at least one element
*/
public static int chooseDigit(int[] digits)
{
    // implementation not shown
}

Which of the following arrays could be passed to the method?

A

[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

B

[9, 7, 4, 6]

C

[10, 9, 8, 7, 6, 5, 4, 3, 2, 1]

D

[8, 4]

E

[ ]

Select an assignment template