Score: 61/66

61/66

Corrections

Question 21

q21 The answer was E because the reset method returns nothing because of the void keyword. Public methods can access private variables in same class.

Question 22

q22 The count method contains two for loops. The outer for loop will iterate through each row in the things array. The inner for loop will iterate through all but the last element in each column. Therefore, if the last element in any column of the two-dimensional input array contains the string “a”, the total count will be incorrect. That is the case for this option, so the method will not work as intended. The Boolean expression in the inner for loop should be c < things[r].length instead of c < things[r].length - 1.

Question 37

q37 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 56

q56 k++ shouldn’t run if the duplicate exists because the length decreases by 1 after removing an element.

Question 62

q62 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. The value 11 is an odd number greater than 9. If x is an odd number but not greater than 9, then y is assigned the value 1. The value 9 is an odd number that is not greater than 9.