Professional Documents
Culture Documents
Ap21 SG Computer Science A q1 q4 PDF
Ap21 SG Computer Science A q1 q4 PDF
AP Computer Science A
®
Scoring Guidelines
© 2021 College Board. College Board, Advanced Placement, AP, AP Central, and the acorn logo are registered
trademarks of College Board. Visit College Board on the web: collegeboard.org.
AP Central is the official online home for the AP Program: apcentral.collegeboard.org.
AP® Computer Science A 2021 Scoring Guidelines
1-Point Penalty
v) Array/collection access confusion ([] get)
w) Extraneous code that causes side-effect (e.g., printing to output, incorrect precondition check)
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
• Extraneous code with no side-effect (e.g., valid precondition check, no-op)
• Spelling/case discrepancies where there is no ambiguity*
• Local variable not declared provided other variables are declared in some part
• private or public qualifier on a local variable
• Missing public qualifier on class or constructor header
• Keyword used as an identifier
• Common mathematical symbols used for operators (× • ÷ ≤ ≥ <> ≠)
• [] vs. () vs. <>
• = instead of == and vice versa
• length/size confusion for array, String, List, or ArrayList; with or without ( )
• Extraneous [] when referencing entire array
• [i,j] instead of [i][j]
• Extraneous size in array declaration, e.g., int[size] nums = new int[size];
• Missing ; where structure clearly conveys intent
• Missing { } where indentation clearly conveys intent
• Missing ( ) on parameter-less method or constructor invocations
• Missing ( ) around if or while conditions
*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 "int G=99, g=0;", then uses "while (G < 10)" instead of
"while (g < 10)", the context does not allow for the reader to assume the use of the lower case
variable.
Canonical solution
(a) 5 points
(b) 4 points
3 Loops through all necessary substrings of Responses will not earn the point if they 1 point
secret (no bounds errors) skip overlapping occurrences
4 Counts number of identified occurrences Responses can still earn the point even if 1 point
of guess within secret (in the they
context of a condition involving both • initialize count incorrectly or not at all
secret and guess) • identify occurrences incorrectly
5 Calculates and returns correct final score Responses will not earn the point if they 1 point
(algorithm) • initialize count incorrectly or not at all
• fail to use a loop
• fail to compare guess to multiple
substrings of secret
• count the same matching substring more
than once
• use a changed or incorrect guess
length when computing the score
(b) findBetterGuess
7 Compares the scores Responses will not earn the point if they 1 point
• only compare using == or !=
• fail to use the result of the comparison
in a conditional statement
8 Determines which of guess1 and Responses can still earn the point even if 1 point
guess2 is alphabetically greater they reverse the comparison
1-Point Penalty
v) Array/collection access confusion ([] get)
w) Extraneous code that causes side-effect (e.g., printing to output, incorrect precondition check)
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
• Extraneous code with no side-effect (e.g., valid precondition check, no-op)
• Spelling/case discrepancies where there is no ambiguity*
• Local variable not declared provided other variables are declared in some part
• private or public qualifier on a local variable
• Missing public qualifier on class or constructor header
• Keyword used as an identifier
• Common mathematical symbols used for operators (× • ÷ ≤ ≥ <> ≠)
• [] vs. () vs. <>
• = instead of == and vice versa
• length/size confusion for array, String, List, or ArrayList; with or without ( )
• Extraneous [] when referencing entire array
• [i,j] instead of [i][j]
• Extraneous size in array declaration, e.g., int[size] nums = new int[size];
• Missing ; where structure clearly conveys intent
• Missing { } where indentation clearly conveys intent
• Missing ( ) on parameter-less method or constructor invocations
• Missing ( ) around if or while conditions
*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 "int G=99, g=0;", then uses "while (G < 10)"
instead of "while (g < 10)", the context does not allow for the reader to assume the use of the lower
case variable.
Canonical solution
9 points
5 Calls getNumSeats on a SingleTable Responses can still earn the point even if 1 point
object they call getNumSeats on constructor
parameters or local variables of type
SingleTable in the constructor
8 Calls getHeight and Responses can still earn the point even if 1 point
getViewQuality on SingleTable they call getHeight or
objects getViewQuality on constructor
parameters or local variables of type
SingleTable in the constructor
Question-specific penalties
None
1-Point Penalty
v) Array/collection access confusion ([] get)
w) Extraneous code that causes side-effect (e.g., printing to output, incorrect precondition check)
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
• Extraneous code with no side-effect (e.g., valid precondition check, no-op)
• Spelling/case discrepancies where there is no ambiguity*
• Local variable not declared provided other variables are declared in some part
• private or public qualifier on a local variable
• Missing public qualifier on class or constructor header
• Keyword used as an identifier
• Common mathematical symbols used for operators (× • ÷ ≤ ≥ <> ≠)
• [] vs. () vs. <>
• = instead of == and vice versa
• length/size confusion for array, String, List, or ArrayList; with or without ( )
• Extraneous [] when referencing entire array
• [i,j] instead of [i][j]
• Extraneous size in array declaration, e.g., int[size] nums = new int[size];
• Missing ; where structure clearly conveys intent
• Missing { } where indentation clearly conveys intent
• Missing ( ) on parameter-less method or constructor invocations
• Missing ( ) around if or while conditions
*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 "int G=99, g=0;", then uses "while (G < 10)" instead of
"while (g < 10)", the context does not allow for the reader to assume the use of the lower case
variable.
Canonical solution
(a) 3 points
(b) 6 points
1-Point Penalty
v) Array/collection access confusion ([] get)
w) Extraneous code that causes side-effect (e.g., printing to output, incorrect precondition check)
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
• Extraneous code with no side-effect (e.g., valid precondition check, no-op)
• Spelling/case discrepancies where there is no ambiguity*
• Local variable not declared provided other variables are declared in some part
• private or public qualifier on a local variable
• Missing public qualifier on class or constructor header
• Keyword used as an identifier
• Common mathematical symbols used for operators (× • ÷ ≤ ≥ <> ≠)
• [] vs. () vs. <>
• = instead of == and vice versa
• length/size confusion for array, String, List, or ArrayList; with or without ( )
• Extraneous [] when referencing entire array
• [i,j] instead of [i][j]
• Extraneous size in array declaration, e.g., int[size] nums = new int[size];
• Missing ; where structure clearly conveys intent
• Missing { } where indentation clearly conveys intent
• Missing ( ) on parameter-less method or constructor invocations
• Missing ( ) around if or while conditions
*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 "int G=99, g=0;", then uses "while (G < 10)"
instead of "while (g < 10)", the context does not allow for the reader to assume the use of the lower
case variable.
Canonical solution
(a) 3 points
(b) 6 points