Final Score

mainscore

Corrections

Question 2 - Outer Loops

wrong1

Time: 5 minutes
Correction: A. The outer for loop iterates three times with r being assigned the values 3, 2, and 1. The two inner loops iterates a different number of times for each iteration of the outer loop depending on the value of r. During the first iteration of the outer loop, when r is 3, the first inner loop iterates two times for when c is equal to 1 and 2. This results in – being printed. The second inner loop iterates one time for when c equals 3. This results in * being printed.

Question 3

wrong2

Time: 3.5 minutes
Correction: B, because the object that was created is of type B, so the show method in class B is called which prints B.

Question 12 - Demorgans Law Practice

wrong3

Time: 10 seconds (Guessed)
Correction: B. Using Demorgans Law. When x and y are both true, !x && !y is false. Therefore, (x && y) && (!x && !y) will always be false as will (x && y) && !(x ||y).

Question 25

wrong4

Time: 1 minute (Educated Guess)
Correction: C. The outer loop iterates four times (for x = 0, 1, 2, 3). When x is assigned 4, the loop terminates. The inner loop will iterate from the value of x to 4, not including 4.

Question 31

wrong5

Time: 2 minutes
Correction: E. The first set of nested for loops sets each element in board to “O”. The next for loop starts val at 0 and increments by 1 until val is 4, when val is 5 the loop terminates. When val is even, board is not updated, so nothing happens when val is 0. When val is 1, row is assigned 1 and col is assigned 0. I still don’t sort of understand, lets ask Mr. Mort in class tomorrow.

Question 32

wrong6

Time: 1 minute (Educated Guess)
Correction: B. To calculate the average age in a given major, you have to find all the students in the given major, add up their ages, and divide by the total number of students in the major. Since theMajor is a String, the if statement needs to use .equals to compare theMajor with the major of k, found by calling the getMajor() method on k.

Question 35

wrong7

Time: 3 minutes
Correction: C. In the first iteration of the binary search, it will check the value at index (0 + 7) / 2 which is index 3. Since 8 is greater than data[3], start is assigned mid + 1 which is 4 and the process will repeat.

Question 36

wrong8

Time: 16 seconds (quick guess)
Correction: D. he first iteration would check the middle element of 2000 and eliminate approximately 1000 elements. The second iteration would check the middle element of 1000 and eliminate approximately 500 elements. The third would eliminate approximately 250 elements. The fourth would eliminate approximately 125 elements AND SO ON!!!

Question 39

wrong9

Time: 11 seconds (google search was wrong)
Correction: C. The first for loop uses the set method to change the value of each element in students to “Alex”. When the set method is called, it returns the value that was originally at this index. So, the first loop will print Alex Bob Carl. At this point all elements have been set to “Alex”. The second for loop uses an enhanced for loop to access every element and will print Alex Alex Alex.