Practice Test FRQ Grading Key
Practice Test FRQ Grading Key
1-Point Penalty
(w) Extraneous code that causes a side effect or prevents earning points in the rubric
(e.g., information written to output)
(x) Local variables used but none declared
(y) Destruction of persistent data (e.g., changing value referenced by parameter)
(z) Void method or constructor that returns a value
No Penalty
o Extraneous code that causes no side effect
o Extraneous code that is unreachable and would not have earned points in rubric
o Spelling/case discrepancies where there is no ambiguity*
o Local variable not declared, provided that other variables are declared in some part
o private qualifier on local variable
o Missing public qualifier on class or constructor header
o Keyword used as an identifier
o Common mathematical symbols used for operators (x • ÷ < > < > ≠)
o [] vs. () vs. <>
o = instead of == (and vice versa)
o Array/collection element access confusion ([] vs. get for r-values)
o Array/collection element modification confusion ([] vs. set for l-values)
o length/size confusion for array, String, and ArrayList, with or without ()
o Extraneous [] when referencing entire array
o [i,j] instead of [i][j]
o Extraneous size in array declaration, (e.g., int[size] nums = new int[size];)
o Missing ; provided that line breaks and indentation clearly convey intent
o Missing { } where indentation clearly conveys intent and { } are used elsewhere
o Missing ( ) on parameter-less method or constructor invocations
o Missing ( ) around if/while conditions
o Use of local variable outside declared scope (must be within same method body)
o Failure to cast object retrieved from nongeneric collection
* Spelling and case discrepancies for identifiers fall under the “No Penalty” category only if the correction can be unambiguously
inferred from context; for example, “ArayList” instead of “ArrayList”. As a counterexample, note that if the code declares
“Bug bug;” and then uses “Bug.move()” instead of “bug.move()”, the context does not allow for the reader to assume
the object instead of the class.
+1 Checks for null reference in array and avoids dereferencing it (in context of loop)
+1 Identifies and provides different treatment of null and non-null elements in array
+1 On exit: The number, integrity, and order of all identified non-null elements in spaces
is preserved, and the number of null elements is preserved
Question-Specific Penalties
-1 (z) Attempts to return a value from consolidate
Part (a):
public int findHorseSpace(String name) {
for (int i = 0; i < this.spaces.length; i++) {
if (this.spaces[i]!=null && name.equals(this.spaces[i].getName())) {
return i;
}
}
return -1;
}
Part (b):
public void consolidate() {
for (int i = 0; i < this.spaces.length-1; i++) {
if (this.spaces[i] == null) {
for (int j = i+1; j < this.spaces.length; j++) {
if (this.spaces[j] != null) {
this.spaces[i] = this.spaces[j];
this.spaces[j] = null;
j = this.spaces.length;
}
}
}
}
}
These canonical solutions serve an expository role, depicting general approaches to solution. Each reflects only one instance from the
infinite set of valid solutions. The solutions are presented in a coding style chosen to enhance readability and facilitate understanding.
Question 2: TokenPass
+1 Initializes all entries in board with computed random value (no bounds errors)
Question-Specific Penalties
-2 (v) Consistently uses incorrect array name instead of board
Question 2: TokenPass
Part (a):
public TokenPass(int playerCount)
{
board = new int[playerCount];
for (int i = 0; i < playerCount; i++){
board[i] = 1 + (int) (10 * Math.random());
}
currentPlayer = (int) (playerCount * Math.random());
}
Part (b):
public void distributeCurrentPlayerTokens()
{
int nextPlayer = currentPlayer;
int numToDistribute = board[currentPlayer];
board[currentPlayer] = 0;
These canonical solutions serve an expository role, depicting general approaches to solution. Each reflects only one instance from the
infinite set of valid solutions. The solutions are presented in a coding style chosen to enhance readability and facilitate understanding.