Score: 50/66

Reflection

I think the questions I struggled with the most were the code-based questions because I was out of practice and took a lot of time on them. I also missed some boolean questions because I didn't try to fully work them out with De Morgan's Law. In preparation for the AP Exam I will practice more with booleans and work through each problem completely instead of rushing. I will focus on nested loops because a lot of the problems with matrices threw me off.

Question 5

The answer is A, not D. The two ! signs applied to the first term cancel out because we're distributing with De Morgan's law, so the first term is just (a && b).

Question 6

The answer is A, not B. randomNumber = 0.70 shows that the code block does not work because of the two consecutive if statements. The event value is first properly assigned as 1, but then changed to 2 because of the following if statement.

Question 10

The condition tested should be for when grade < 80 because it is the only situation in which both segments only increment the point counter once.

Question 12

When distributing 2 conditions in a && statement to a || statement , the format should be (||) && (||). The correct answer is (y > 10000 | | x > 1000) && (y > 10000 | | x < 1500). The answer should be true when x is between 1000 and 1500.

Question 17

I misread the code and thought that the function was checking for all instances of the substring "ab" in the string, which occurs once. It's really checking for all the instances with substring "a" followed by a character that is not "b". This occurs 5 times.

Question 21

I overlooked the "void" return type for reset. It means that reset doesn't return a value, so the code segment will not be able to print the new password.

Question 22

The correct answer is D because the method will skip over the last element in each column and not count "hat" or "pants". I missed this question because I misread the nested for loop conditions.

Question 28

Similarly to the last question, I missed this one because I mixed up the iterative variables. The correct answer is D because after the first 3 is removed at index 3, the counter j is increased to 4 and so the program skips over the second low score that is now at index 3.

Question 42

I didn't realize that this program was a palindrome checker because I was rushing and didn't read through the example fully. The answer should be E, "noon", because the original and temporary reversed strings are equal.

Question 50

The nested loops confused me so I ended up guessing C. The correct answer is D. The loop repeats num1 times from 0 to num1-1, and checks for even numbers that are also divisible by num2. Setting 20 as num1 and 5 as num2 will return 0 10.

Question 52

I chose C because I was looking for an answer with "price += surcharge" so that the price value would be raised. However I missed the "void" access type for raisePrice which meant that the method won't return anything. The correct answer is B.

Question 53

The mystery2 method uses a while loop that takes the opposite conditions from mystery1 to iterate and modify total. One difference between the two methods is that mystery2 needs to have total initialized as 1, not 0.

Question 54

The answer is D because the string is in backwards alphabetical order. This means that because the base character is lexicographically greater than the second character, the method will return true and continue until the last letter.

Question 58

Because j is used as a tracking variable for the for loop and pos is another tracker for a loop nested in the for loop, line 2 should be changed to set pos equal to j. This means the correct answer is B.

Question 59

The first test case will work even if there is only one element in the array, and the method will return 0. However, the second test case will eventually lead to a call for an index that is not in the array, resulting in an error. Therefore the correct answer is B.

Question 63

I misread the problem and thought that swapping lines 5 and 9 would resolve any potential bugs. However, the best solution is to remove the else code block because it modifies arr1, which should be unchanged.