College Board MCQ Corrections.

Question: #5 CollegeBoard

The correct answer to this problem would be A: ( a && b ) && ( !c && d ).

Question: #12 CollegeBoard

The correct answer to this problem would be A: (y > 10000 | | x > 1000) && (y > 10000 | | x < 1500) because the original expression evaluates to true when either y is greater than 10000 or x is between 1000 and 1500.

Question: #18 CollegeBoard

The correct answer to this problem would be E becausethe original expression prints "dog" when a < b || c != d evaluates to true, an equivalent code segment would print "cat" when the negative of the expression, or !(a < b || c != d), evaluates to true.

Question: #19 CollegeBoard

The correct answer to this problem would be A; because of De Morgan's laws, the given expression is equivalent to (a < b) || (c < d).

Question: #23 CollegeBoard

The correct answer to this problem would be B, because the last array element is at index arr.length - 1, so the loop should only iterate while j < arr.length.

Question: #25 CollegeBoard

The correct answer to this problem would be B, because the mutator method updateItems must have a return type. In this case, since no value is returned, the return type should be void.

Question: #29 CollegeBoard

The correct answer to this problem would be S, because the issue with the code segment is that, in the outer for loop header, the condition j < arr.length - 1 should be replaced with j < arr.length so that the code segment will also traverse the last row in the two-dimensional array. As written, the code segment will traverse all the rows in the array except for the last row.

Question: #34 CollegeBoard

The correct answer to this problem would be D, because the original code segment uses an enhanced for loop to iterate through the elements of array arr, uses variable sum to accumulate the sum of twice the value of the elements in the array, and prints the value of sum. This code segment produces the same output using a regular for loop.

Question: #36 CollegeBoard

The correct answer to this problem would be C.

Question: #39 CollegeBoard

The correct answer to this problem would be A, because the value 1900 is a multiple of 4, so the expression (val % 4) == 0 evaluates to true and the statement return true; is executed, thereby exiting the method with a return value of true. This is an error because even though 1900 is a multiple of 100, it is not a multiple of 400, so the method should have returned false.

Question: #41 CollegeBoard

The correct answer to this problem would be B, 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: #56 CollegeBoard

The correct answer to this problem would be B, Line 2 should be changed to int pos = j;

Question: #58 CollegeBoard

The correct answer to this problem would be C, The last element of the returned array (result [result.length − 1] ) may not have the correct value.

Question: #60 CollegeBoard

The correct answer to this problem would be C, because the first conditional tests to see if x is even, if it is, y will be assigned the value 3. The value 8 is an even number and will test this condition. If x is not even, then the second test will check if x is greater than 9. If x is an odd number greater than 9, then y will be assigned the value 5.