Score: 48/66 or 73%

Experience

The test took me roughly over 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 9

  • Answer is choice > 10 because when choice is greater than 10, code segment A will print "blue" and the else statements are not executed. Code segment B will print "blue" but will then execute the next if statement and print "yellow." So, different values will be produced.

Question 10

  • Answer: The two code segments print the same value only when grade is below 80. Code segment I uses else statements so points increase by a single digit. Code segment II does not use else statements and points can increase multiple times. 80 and above is when the segments print the same.

Question 16

  • Line 8 should be changed to for (int[] row: arr) because Line 8 should assign a row a 1D array of numbers. The original code tries to assign a row of col, but col is not a two-dimensional array.

Question 19

  • (a < b) || (c < d) because using De Morgan's law, the given expression is the same as this one

Question 24

  • Answer: 5, 10, 15, 20, 25, 30, 35, 40 because the Boolean expression in the outer loop is row <= arr.length instead of row < arr.length. Any value of arr that doesn't have 0 can be used to show that the method does not work as intended.

Question 33

  • The largest value in the arr is negative since maxVal is initialized to a value that is greater than all values in arr, maxVal will never be updated and 0 will be returned. To correct this, maxVal could be initialized to the first element in arr or initialized to Integer.MIN_VALUE.

Question 35

  • Answer: int count = 0;

for (int k = 9; k >= 0; k--)

{

count++;

}

System.out.println(count);

The loop iterates 10 times. In each iteration, count is incremented by 1. Since the initial value of count is 0, the printed value of count is 10.

Question 36

  • Line 4 only

Question 37

  • Answer: boolean b2 = (num < -100) || (num > 0 && num < 100); because in the body of the first if clause in the code segment, b1 retains the value true if num is between 0 and 100, exclusive. In the body of the else clause, b1 retains the value true if num is less than -100. The statement assigns true to b2 if num is less than -100 or between 0 and 100, exclusive.

Question 40

  • Answer: Insert the following statement before Line 1.

    if (numVals == 1

    return nums[0];

Question 41

  • Answer: mystery(true, false, true) because since a is true, !a is false and the body of the first if statement is not executed. Since b is false, the body of the second if statement is not executed. Since c is true, the body of the third if statement is executed and the value 7 + 4 = 11 is returned.

Question 45

  • Answer: In lines 1, 2, and 3, the text that appears in parentheses should be enclosed in quotation marks.

Question 51

  • The answer is 22 because in the original method, the call puzzle(22) returns 20. The first condition evaluates to true, so x is decreased by two and 20 is returned. In the original method, when the condition in the if statement evaluates to true, the second condition, in the else if clause, is not evaluated. For the modified method, the first condition still evaluates to true and x is decreased by two. But now the second condition appears in an if statement, instead of in an else if clause, so the second condition is evaluated, found to be true, and x is increased by four. This results in the value 24 being returned.

Question 56

  • Answer: There should be an else before the statement k++;

Question 58

  • Answer: Line 2 should be changed to

    int pos = j;

Question 64

  • Answer: III only because the given code segment prints the array elements in order from left to right using an enhanced for loop. Code segment I uses elements as indices. The first element of arr is 1, and arr[1] is 2; the second element is 2, and arr[2] is 4; the third element is 4, and arr[4] is 3; etc. Code segment II prints the indices 0 to 4 in order. Code segment III prints the array elements in order from left to right using a for loop.

Question 65

  • Answer: 115