2015 MCQ & FRQ Review
📝 CollegeBoard MCQ/FRQ Corrections
2015 MCQ
Q31:
Which of the following represents the board after this code segment is executed?
Why the question is wrong: Incorrect. This image would require the second set of nested loops to initialize row
to val – 1
, increment both row
and col
in each iteration inner loop (instead of row
being decremented) and change the condition on the inner loop to col < 5 && row < 5
. Essentially, I ran the code backwards and messed up the battens of the diagonals. I misunderstood how the X placement logic works within the nested loop. The loop positions X diagonally whenever the value is odd. It begins at (row = val, col = 0) and moves diagonally downward, ensuring it remains within the boundaries of the 5x5 grid. I accidentally selected an option that didn’t align with the expected diagonal pattern of X placements.
How to improve: As much as paper is discouraged in class, it will be important on the exam because it will help me to keep track of variables. I should trace through the loops and write down what is happening.
Q3:
What is printed as a result of executing the following code segment?
Why the question is wrong: Incorrect. References declared of the superclass type can be assigned objects of the subclass. Since there is a show
method in the superclass a runtime error does not occur. With inheritance we are allowed to override a method from the superclass in the subclass. For some reason, I thought that the function would not be overloaded. I don’t know why I thought this, but that is not what happens. I thought you needed a key like @Override
or something similar, but it works normally without anything too.
How to improve: I should go to previous lessons on classes to remember the topics. It has been a while since I reviewed those topics, so it makes sense that I may have forgotten them.
Q1:
Which of the following can be used to replace / condition / so that numDivisors will work as intended?
Why the question is wrong: Incorrect. This would be the correct solution if we wanted to know if k
was evenly divisible by inputVal
. I wasn’t paying attention and flipped the variables, but that is not what the function is looking for.
How to improve: One thing I noticed was that College Board uses vaguely named variables and function names with no comments. In real life, you don’t do that. However, we just have to deal with that here. I think that may be why I wasn’t paying attention and flipped the variables. Instead, I should try inputting a test value and write down the result to see which answer is correct.
2015 FRQ
Rubric Grade
Description | Pts | Done? |
Used the correct class, constructor, and method headers | 1 | ✔️ |
Declared private instance variable | 1 | ✔️ |
Initialized the instance variable properly in the constructor | 1 | ✔️ |
Implemented getHint method: | ||
Looped through all letters in both guess and hiddenWord without index errors. | 1 | ✔️ |
Implemented getHint method >> Processed each letter correctly: | ||
Extracted and compared letters from guess and hiddenWord | 1 | ✔️ |
Checked if letters were in the same position | 1 | ✔️ |
Checked if letters were in the word but in the wrong spot | 1 | ✔️ |
Added the correct character (letter, +, or *) to the hint | 1 | ✔️ |
Constructed and returned the hint string | 1 | ✔️ |
public class HiddenWord {
private final String word;
public HiddenWord(String word) {
this.word = word;
}
public String getHint(String guess) {
StringBuilder hint = new StringBuilder();
int[] letterFrequencies = new int[26];
// Count occurrences of letters in hidden word
for (char c: word.toCharArray()) {
letterFrequencies[c - 'A']++;
}
// First pass: Identify exact matches
for (int i = 0; i & lt; word.length(); i++) {
if (guess.charAt(i) == word.charAt(i)) {
hint.append(guess.charAt(i));
letterFrequencies[guess.charAt(i) - 'A']--;
} else {
hint.append('.');
}
}
// Second pass: Identify misplaced letters
for (int i = 0; i & lt; word.length(); i++) {
if (hint.charAt(i) == '.') {
char guessChar = guess.charAt(i);
if (letterFrequencies[guessChar - 'A'] > 0) {
hint.setCharAt(i, '+');
letterFrequencies[guessChar - 'A']--;
} else {
hint.setCharAt(i, '*');
}
}
}
return hint.toString();
}
public static void main(String[] args) {
HiddenWord puzzle = new HiddenWord("HARPS");
System.out.println(puzzle.getHint("AAAAA")); // Expected Output: "*A+++"
System.out.println(puzzle.getHint("HARPS")); // Expected Output: "HARPS"
System.out.println(puzzle.getHint("SHARP")); // Expected Output: "+HARP"
}
}