?

AP® Computer Science A

Free Version

Upgrade subject to access all content

Moderate

Evaluation of Post-Condition for a Method

APCSA-AWYXYV

Consider the following code segment.

/**
* Create an array of random numbers
* @param num number of random numbers to generate
* Precondition: num > 0
* Postcondition: the returned array contains random integers
* from 0-100 excluding both 0 and 100
* Postcondition: numbers are not repeated in the array
*/
public static int[] createRandomDigits(int num)
{
    // implementation not shown
}

Which of the following arrays would be an acceptable output from this method?

A

[ ]

B

[40, 32, 0, 22, 1]

C

[32, 30, 1, 89, 6]

D

[8, 87, 12, 22, 100, 67, 9]

E

[74, 35, 28, 92, 35, 99, 2]