Score: 31/52

Reflection

I think I struggled the most with the questions involving 2D arrays because I'm still not used to the syntax of the loops used with them. I think all of my missed questions were from that category. In the future, I will try to improve my performance on those questions by finding more MCQs and checking the answer after each question to reinforce my knowledge.

Question 4

I chose B because I forgot how the substring indexes worked and thought it would print from index 1 to index 3, not from 1 to 2. The answer is C because it prints BCEF.

Question 5

The answer is E because the nested for loop traverses the array by column, not row. I got confused and chose D.

Question 7

I was confused by the code segment and didn't fully understand what it was meant to do, so I ended up guessing. The correct answer is B because it checks 2 substrings and adds them to res if they match (0 otherwise).

Question 8

I chose B because I forgot how the substring method worked and thought the calls were adding a space between each letter. The substrings used were really removing the first letter from each subsequent string, so the answer would be D.

Question 10

I chose E instead of D because I forgot that primitives could be concatenated with +=.

Question 11

I thought the answer was A but the print operator actually adds the one and two integers together, so it would be 3Z instead of 12Z.

Question 19

I didn't catch the num = k statement in the loop and thought it was B, but the answer is C because num is supposed to have the value of the last index of check.

Question 20

The answer is D because the nested loops are checking each element where the value is greater than j + k.

Question 24

I was confused by the loop's parameters at first and thought there would be an index error. However, the segment will actually end up printing abbccddeef.

Question 32

I thought there would be an IndexOutOfBoundsException but the segment actually checks for the smaller value in a pair and then prints it. It's 3 in both cases, so the output is 3 3.

Question 34

I wasn't sure what the print statement was meant to do so I guessed. The answer is B.

Question 35

I missed that the print statement printed k = the index itself and thought it was printing the value at the index. The correct answer is C.

Question 37

I guessed because I couldn't figure out what was happening in the processWords method. The answer is A.

Question 40

I thought II and III would work but II doesn't work because the parameters are wrong. The answer is C, III only.

Question 41

I got two of the lists confused and thought the program fails because it removes the element before adding to the other list. The correct answer is E, because the index tracker doesn't account for the changing index elements.

Question 42

I didn't realize that the program removed all zeroes but skipped the 0 at index 0. The correct answer is D.

Question 43

I thought the substring calls would be thrown out of bounds but giving "compiler" as a string actually returns "ilercom".

Question 45

I thought sm was updated whenever a shorter string was found but it's actually updated whenever a new smallest value is found.

Question 46

I was confused by the code segments and just guessed. The correct answer is B because you're finding the average age of students in a major.

Question 48

I didn't think I would work but it actually does, just uses a traditional for loop to traverse the array. The only option that odesn't work is III, so the answer is D.

Question 50

I guessed on this one. The correct answer is C.