Question 4

Assume that a, b, and c are boolean variables that have been properly declared and initialized. Which of the following boolean expressions is equivalent to !(a && b) || c ?

A a && b && c

B a || b || c

C !a && !b || c

D !a && !b && c

E !a || !b || c

  • I didn't realize that B is not equivalent to the given expression when all the values are false. So E is the right answer by De Morgan's laws.

Question 27

q27

For the option I chose, the method does work as intended since it removes the elements that were initially at indexes 0 and 3. In option B, the variable j is sometimes increased by 1 twice.

Question 32

q32

I misunderstood how the findLongest method worked. If lenCount = 0 is added between lines 12 and 13, then the method will find the longest consecutive block of the value target occurring in the array.

Question 33

q33

If the largest value occurs more than once, the method would still work since the maxVal would already be set to the max value. However, if the largest value is negative, then 0 will be returned. This could be fixed if maxVal was initialized to the first element in the array.

Question 34

q34

The selected code would print a value that is twice the sum. The right answer uses a regular loop as opposed to an enhanced loop to give the same answer as the code above.

Question 35

q35

The selected code would print 10 while we want to print 11. The right answer increases count by 1 each time the loop runs so count will be 10 at the end since it started at 0.

Question 36

q36

For this question, I need to learn more about the GridWorld case study.

Question 53

q53

If the variable total is initialized to 1, then mystery2 will return the same value as mystery1. Variable x should be initialized to 1.

Question 54

q54

The selected option would return false since a is lexicographically less than b. But in option D, there is no character pair where the first character of str is lexicographically less than or equal to the second character of str so the value returned is true.

Reflection

  • I got 57 out of 66. Taking this quiz was helpful in practicing AP questions and getting an idea of what areas I need to work on.

  • This quiz took me a couple of hours and I got stuck on some of the questions so I need to work on my timing. I worked on the quiz at different times and found that I got more questions wrong near the end of the times I worked on the quiz.

  • One area I could work on more is recursion by looking at Unit 10. I could also review Unit 6 Arrays and Unit 9 Polymorphism.