CB Exam Prep
I took the 2020 Practice MC here are some of the key topics I missed:

Here are some of the major questions I got wrong:
Question 3:

Key Concept: Using objects + Primitives
❌ My Answer: D double hours = Math.abs((marker1 - marker2) / 60);
📌 Why I Picked This Answer: I chose this answer because it seemed to follow the intended logic: subtracting the two mile markers, taking the absolute value to ensure positive distance, and then dividing by 60 to convert miles into hours at a speed of 60 mph. The parentheses made it seem like the operations were grouped correctly.
🛑 Why This Answer Is Wrong: This line uses integer division because both marker1 and marker2 are integers. The division occurs before the result is cast or assigned to a double. For example, with marker1 = 100 and marker2 = 70, the expression (100 - 70) / 60 becomes 30 / 60, which equals 0 (since it’s integer division). This 0 is then stored as 0.0 in the double, which is incorrect—the expected value is 0.5.
✅ Correct Answer: C double hours = Math.abs(marker1 - marker2) / 60.0;
✔️ Why This Answer Is Right: This version correctly calculates the absolute difference between the two markers and then divides that difference by 60.0. Using 60.0 ensures floating-point division, which maintains the decimal value.
For example, with marker1 = 100 and marker2 = 70, the calculation becomes Math.abs(100 - 70) / 60.0 = 30 / 60.0 = 0.5, which is the correct and intended result.
Question 20:

Key Concept: Arrays
❌ My Answer: C if (Book[b].pages > maxPages) { maxPages = Book[b].pages; }
📌 Why I Picked This Answer: I picked this answer because I thought I needed to use the class name Book to reference elements of the array and assumed b could somehow be used as an index. The syntax seemed close to what I’d seen in other array examples, and I was focused on trying to access the pages variable directly.
🛑 Why This Answer Is Wrong: There are several issues with this code:
Book[b] is invalid syntax. Book is a class name, not an array. You can’t use it like Book[b].
b in the enhanced for loop (for (Book b : bookArr)) is an actual Book object, not an index. So trying to use it as an index doesn’t make sense.
Even if you could reference a Book object, pages is a private instance variable, which means you can’t access it directly from outside the class. Instead, you need to use the getter method getPages() that was provided.
✅ Correct Answer: B if (b.getPages() > maxPages) { maxPages = b.getPages(); }
✔️ Why This Answer Is Right:
It uses b, the current Book object in the loop.
It accesses the number of pages using the public accessor method getPages(), which is the correct way to access private data.
The logic correctly checks if the current book has more pages than maxPages, and updates maxPages if so.
This approach works exactly as intended and respects both the rules of enhanced for-loops and object-oriented encapsulation.
Question 33:

Key Concept: 2D Arrays
❌ My Answer: D I chose D because it looked like a typical left-to-right, row-by-row print pattern and seemed visually neat. I assumed that the outer loop handled rows and the inner loop handled columns, or I didn’t notice that the loop starts at index 1 for both col and row.
🛑 Why D Is Incorrect Let’s analyze the code:
String[][] letters = { {“A”, “B”, “C”, “D”}, {“E”, “F”, “G”, “H”}, {“I”, “J”, “K”, “L”} };
for (int col = 1; col < letters[0].length; col++) { for (int row = 1; row < letters.length; row++) { System.out.print(letters[row][col] + “ “); } System.out.println(); } The outer loop (col = 1 to 3) loops through columns of the array.
The inner loop (row = 1 to 2) loops through rows.
The value at letters[row][col] is printed for each iteration, skipping row = 0 and col = 0.
Let’s compute what gets printed:
col = 1: prints letters[1][1] = F, letters[2][1] = J → F J
col = 2: prints letters[1][2] = G, letters[2][2] = K → G K
col = 3: prints letters[1][3] = H, letters[2][3] = L → H L
What actually prints:
F J G K H L ✅ Correct Answer: E This matches the correct answer shown in your screenshot. Option E displays:
F J G K H L Exactly what the code prints!
✔️ Why E Is Correct It correctly reflects the order in which the nested loop accesses the array.
It follows the proper indices based on the loop setup.
The code starts at the second row and column (index 1), which is crucial to understanding the correct output.