Score: 39/52 or 75%

Experience

The test took me roughly an hour to complete. I had to guess on some of the questions and reference google and different websites. I definitely am rusty on multiple choice after not practicing it for a long time. I feel like we spent a lot of time on FRQ review so far this trimester that I'll perform better on that section of the test. I feel as though I did better on the recursion problems though which was a concept I struggled with on the test we took at the end of Trimester 1.

Weak Areas

  • 2D Arrays
  • Traversing 2D Arrays
  • String Methods
  • Array Lists
  • Traversing Array Lists

Question 2

  • Every element in the 4 by 4 array is modified except the first row and column which remains 1. Each element in the row is replaced by the sum of the element above and to the left. In row 1, mat [1][1] is assigned mat[0][1] + mat[1][0] = 1+1 =2. Continuing this pattern, the answer is 10.

    1 1 1 1

    1 2 3 4

1 3 6 10 


1 1 1 1

Question 4

  • The answer is BCEF The call oldStr.substring(1, 3) returns the substring of oldStr starting at index 1 and ending at index 2, or "BC"; the call oldStr.substring(4) returns the substring of oldStr starting at index 4 and going to the end of oldStr, or "EF". Therefore, as the result of the concatenation operation "+", newStr gets assigned the value "BCEF".

Question 6

  • The answer is the column index of an element with the largest value in the 2-D array. The result has to do with the "y" variable which is the column number. The greater than sign indicates that the result will be the largest value in the array.

Question 8

  • Silly mistake. The answer is comp, omp, mp, and p because the statement concatenates return values separated by space based on the substring.

Question 13

  • The answer is containsArt ("rattrap", "similar", "today") because the method should return false since none of the words contain "art."

Question 14

  • Line 8 should be changed to for (int[] row: arr) because because 2-D arrays are stored as arrays of one-dimensional arrays. Line 8 is supposed to assign to row, a one-dimensional array of int values, a single row of the two-dimensional array arr. The original version of line 8 attempts to assign a row of col, but col is not a two-dimensional array.

Question 19

  • The answer is the index of last occurrence of check inside str because the for loop assigns values to k from 0 to the last possible position in str at which check could appear, inclusive. In the body of the loop, the String a is assigned a substring of check that starts at position k and has the same length as check. If the substring a and check are the same, num is assigned k. When the for loop ends, num has the last value of k at which a match between the substring a and check was found or the index of the last occurrence of check in str.

Question 26

  • The answer is mystery ("noon") because the algorithm assigns temp the letters of str in reverse by extracting each letter of str starting at the end and moving to the beginning. Each letter is appended to the end of temp. So, if str was “abc”, “c” would be appended followed by “b”, and then “a”, making temp equal to “cba”. This method will return true if str is equal to temp, which is a string with the letters of str in reverse. The string “noon” is the only string that is the same in reverse.

Question 28

The answer is [8, 4, 3, 6, 11, 1, 12, 9, 7]

Question 30

  • The answer is because based on the code, numbers in the first, second, and third row are being deleted

    15 14 13 12 11

    25 24 23 22

    35 34 33

    45 44

Question 35

  • The answer is 3 2 1 because the code segment iterates over numbers from right-to-left and prints the values that are greater than their index. The element at index 3, which is 5, is greater than 3, so 3 is printed. The element at index 2, which is 4, is greater than 2, so 2 is printed. The element at index 1, which is 2, is greater than 1, so 1 is printed. The element at index 0, which is 0, is not greater than 0, so 0 is not printed.

Question 44

  • The answer is {"of", "of", "of", "spring"} because the method assigns the shortest string that occurs in any element of arr between arr[n] and arr[arr.length - 1], inclusive, to result[n]. The shortest string found between arr[0] and arr[3] is "of", so result[0] is assigned the value "of". The shortest string found between arr[1] and arr[3] is also "of", so result[1] is also assigned the value "of". The same is true for the part of the array that begins at index 2 and ends at index 3, so result[2] is also assigned the value "of". In the last iteration of the outer for loop, there are no values to consider after arr[3], so result[3] is assigned the value "spring".

Question 47

  • The answer is 26 because the nested for loops traverse the two-dimensional array values. The first element of each row is doubled and then the sum of all elements is computed as 2+2+3+8+5+6=26