Overall Reflection

  • Score: 32/40
  • I think I definitely could have done better. Some of the problems I got wrong were simple mistakes that could have been avoided if I wrote down each problem on paper to organize my thoughts. In the future I will make sure to write down each step so I can visualize what the code is actually doing rather than keeping each step in my head. Another thing that I want to work is trying to determine what amount of time is enough for each question. I often spend thinking about questions that I am unsure about. Next time, I will try to avoid spending a large portion of my time on questions that I don't know the answer to, and go back to them when I have finished all of the other questions that I know.

Questions

Question 20

image

  • Corrections: Since k is decremented, the last element is only used in the first iteration of the while loop. This method uses a swapping algorithm to swap elements in nums.

Question 23

image

  • Corrections: List is an interface, which an ArrayList implements. This would be the result if when words that started with “b” were found, they were added to the end instead of inserted at index animals.size() – k such as if the statement in the for loop was animals.add(animals.remove(k));.

Question 30

image

  • Corrections: Since the two parameter substring method returns the substring beginning at the first parameter and ending at the second parameter – 1, no IndexOutOfBoundsException will be thrown. The indices 4, 7 (in the first call to substring), 0 and 2 (in the second call to substring) are all valid indices in "compiler".

Question 34

image

  • Corrections: Choice III uses the default Point constructor to assign center a new Point with x and y both equal to 0. It attempts to update x and y, however since they are private instance variables in Point, they are not able to be accessed directly in Circle. This code will cause a compile time error.

Question 37

image

  • Corrections: Choice I works. Choice III works also, as it will cause the while loop to iterate while x is less than 7. The variable x is assigned 1 to start and then incremented by 2. It will be assigned the values 1, 3, 5 and then 7. When x has the value 7, the loop will terminate. The output will be 1, 3, 5.

Question 38

image

  • Corrections: This expression will evaluate to false whenever y is less than 10000 regardless of whether x is in the correct range between 1000 and 1500.

Question 39

image

  • Corrections: The value of recur(6) is 12. However, this call was made within another recursive call and is not the final return value.

Question 40

image

  • Corrections: When whatsItDo(“W”) is called, nothing is printed since the print occurs in the if statement which does not execute. All previous recursive method calls print a substring of str and not str.