Score: 47/52

Reflection

I think this time, I was much stronger on the theoretical aspects of the quiz, but made stupid mistakes because I was rushing. I was able to somewhat remember DeMorgan’s Law, but had to look it up to make sure I was correct. I made mistakes when I was skimming the code and not playing out the recursion or other theoretical questions.

Questions

Question 19

I thought that it would return the index of the first occurrence of check inside str, but it was actually the index of the last occurrence of check inside str. This is due to the fact that you have num = k in the for loop, so the last occurence of check inside str would be the one that is returned.

Question 20

I thought that ! would be printed only twice, but that is not the case as it would actually be printed 6 times. I thought that the operator in the statement was < instead of >, so I thought that it would only print the ! twice.

Question 25

Here, my answer would have been correct if the remove happened before size was calculated in the add statement, but it was not the case here and so it would have caused bear to be at the beginning and baboon at the end.

Question 42

In this case, I forgot that using the remove method would cause the index of the elements to be shifted, throwing an ArrayIndexOutOfBoundsException at the end.

Question 45

I thought that the method is executed once for every loop in the nest for loops, which would be 15 times, but I forgot that the if statement would cause it to only be run the 4 times when the condition is true.