?

AP® Computer Science A

Free Version

Upgrade subject to access all content

Difficult

Testing the Pass Method with an ArrayList of Integers

APCSA-BXVSZJ

Consider the following method.

/** return true if student passes all tests, return false otherwise.
* test scores need to be between 1 and 105.
* a passing score is defined as 70 or greater.
* only taken tests are included in testScores.
* a student has to have at least one test score to be passing.
* @param testScores an array list of test scores
* Pre-condition: each score will be a positive integer
*/
public static boolean pass(ArrayList testScores)
{
    // implementation not shown
}

The following code from the main method is used to test the method:

ArrayList<Integer> testScores = new ArrayList<Integer>();
testScores.add(80);
testScores.add(70);
testScores.add(50);
System.out.println(pass(testScores));

In addition to the above test case, which of the following test cases would be necessary in order to thoroughly test this method?

I.

ArrayList<Integer> testScores = new ArrayList<Integer>();
testScores.add(80);
testScores.add(70);
testScores.add(90);
System.out.println(pass(testScores));

II.

ArrayList<Integer> testScores = new ArrayList<Integer>();
System.out.println(pass(testScores));

III.

ArrayList<Integer> testScores = new ArrayList<Integer>();
testScores.add(80);
testScores.add(-2);
testScores.add(90);
System.out.println(pass(testScores));

IV.

ArrayList<Integer> testScores = new ArrayList<Integer>();
testScores.add(80);
testScores.add(70);
testScores.add(110);
System.out.println(pass(testScores));

V.

ArrayList<Integer> testScores = new ArrayList<Integer>();
testScores.add(78);
testScores.add(66);
testScores.add(99);
System.out.println(pass(testScores));
A

I, II, and IV only.

B

II, III, and V only.

C

III, IV, and V only.

D

I, III, IV and V only.

E

I, II, III, IV and V.