0% found this document useful (0 votes)
15 views14 pages

Ap17 SG Comp Sci A

The document provides the 2017 scoring guidelines for the AP Computer Science A exam, detailing how to assess student responses based on specific rubrics for various questions. It includes penalty points for common errors and outlines the criteria for earning points in different parts of the exam questions. The document also presents canonical solutions as examples of acceptable responses for coding tasks.

Uploaded by

javamanpenguin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views14 pages

Ap17 SG Comp Sci A

The document provides the 2017 scoring guidelines for the AP Computer Science A exam, detailing how to assess student responses based on specific rubrics for various questions. It includes penalty points for common errors and outlines the criteria for earning points in different parts of the exam questions. The document also presents canonical solutions as examples of acceptable responses for coding tasks.

Uploaded by

javamanpenguin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

2017

AP Computer Science A
Scoring Guidelines

© 2017 The College Board. College Board, Advanced Placement Program, AP, AP Central, and the acorn logo
are registered trademarks of the College Board. Visit the College Board on the Web: www.collegeboard.org.
AP Central is the official online home for the AP Program: apcentral.collegeboard.org
AP® COMPUTER SCIENCE A
2017 GENERAL SCORING GUIDELINES

Apply the question assessment rubric first, which always takes precedence. Penalty points can only be
deducted in a part of the question that has earned credit via the question rubric. No part of a question
(a, b, c) may have a negative point total. A given penalty can be assessed only once for a question, even if
it occurs multiple times or in multiple parts of that question. A maximum of 3 penalty points may be
assessed per question.

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
o Extraneous code with no side-effect (e.g., valid precondition check, no-op)
o Spelling/case discrepancies where there is no ambiguity*
o Local variable not declared provided other variables are declared in some part
o private or public qualifier on a local variable
o Missing public qualifier on class or constructor header
o Keyword used as an identifier
o Common mathematical symbols used for operators (× • ÷ < > <> ≠)
o [] vs. () vs. <>
o = instead of == and vice versa
o length/size confusion for array, String, List, or 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 ; where structure clearly conveys intent
o Missing { } where indentation clearly conveys intent
o Missing ( ) on parameter-less method or constructor invocations
o Missing ( ) around if or while conditions

*Spelling and case discrepancies for identifiers fall under the “No Penalty” category only if the correction
can be un am biguousl y 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 n ot allow for the reader to assume the use of the lower
case variable.

© 2017 The College Board.


Visit the College Board on the Web: www.collegeboard.org.
AP® COMPUTER SCIENCE A
2017 SCORING GUIDELINES

Question 1: Digits

Part (a) Digits constructor 5 points


Intent: Initialize instance variable using passed parameter

+1 Constructs digitList

+1 Identifies a digit in num

+1 Adds at least one identified digit to a list

+1 Adds all identified digits to a list (must be in context of a loop)

+1 On exit: digitList contains all and only digits of num in the correct order

Part (b) isStrictlyIncreasing 4 points


Intent: Determine whether or not elements in digitList are in increasing order

+1 Compares at least one identified consecutive pair of digitList elements

+1 Determines if a consecutive pair of digitList is out of order (must be in context of a


digitList traversal)

+1 Compares all necessary consecutive pairs of elements (no bounds errors)

+1 Returns true iff all consecutive pairs of elements are in order; returns false otherwise

Question-Specific Penalties

-2 (q) Uses confused identifier instead of digitList

© 2017 The College Board.


Visit the College Board on the Web: www.collegeboard.org.
AP® COMPUTER SCIENCE A
2017 SCORING GUIDELINES

Question 1: Scoring Notes

Part (a) Digits constructor 5 points


Points Rubric Criteria Responses earn the point if they ... Responses will not earn the point if they ...
• initialize a local variable instead of
Constructs digitList
+1
digitList
• create an ArrayList<int>
• identify one digit of num or a length • treat num itself as a String
Identifies a digit in
+1
num
one substring/character of the • convert num to a String
String representation of num incorrectly
• call add for some ArrayList • add String or char to
Adds at least one
using the previously identified digit, digitList without proper
+1 identified digit to a
even if that digit was identified conversion to the correct type
list
incorrectly
Adds all identified • call add for some ArrayList • identify only 1 digit
digits to a list using previously identified digits,
+1
(must be in the even if those digits were identified
context of a loop) incorrectly
• add to digitList even if it is not • obtain a list with the digits in reverse
On exit: instantiated properly order
digitList • omit one or more digits
+1 contains all and • add extra digits
only digits of num • mishandle edge case, e.g., 0 or 10
in the correct order • make a bounds error processing the
String representation of num
Part (b) isStrictlyIncreasing 4 points
Points Rubric Criteria Responses earn the point if they ... Responses will not earn the point if they ...
• compare two consecutive • access digitList as an array or
Integers using compareTo string
Compares at least
• explicitly convert two consecutive • fail to call .get()
one identified
Integers to ints and compare • compare using !>
+1 consecutive pair of
digitList those with >=, <= etc.
elements • use auto-unboxing to convert two
consecutive Integers to ints
and compare those with >=, <= etc.
Determines if a • determine the correct relationship • fail to consider the case where the
consecutive pair of between the two compared two elements are equal for the false
digitList is consecutive elements, even if the case
+1 out of order (must syntax of the comparison is incorrect
be in context of a
digitList
traversal)
Compares all • return early
necessary
+1 consecutive pairs
of elements (no
bounds errors)
Returns true iff • compare consecutive pairs for • return prematurely via if (...)
all consecutive inequality, but fail to consider the return false; else return
pairs of elements case when two elements are equal true;
+1
are in order;
returns false
otherwise

© 2017 The College Board.


Visit the College Board on the Web: www.collegeboard.org.
AP® COMPUTER SCIENCE A
2017 SCORING GUIDELINES

Question 1: Digits

Part (a)

public Digits(int num)


{
digitList = new ArrayList<Integer>();

if (num == 0)
{
digitList.add(new Integer(0));
}

while (num > 0)


{
digitList.add(0, new Integer(num % 10));
num /= 10;
}
}

Part (b)

public boolean isStrictlyIncreasing()


{
for (int i = 0; i < digitList.size()-1; i++)
{
if (digitList.get(i).intValue() >= digitList.get(i+1).intValue())
{
return false;
}
}
return true;
}

Note: The solutions shown above were written in compliance with the AP Java subset methods listed for
Integer objects. Students were allowed to use the automatic "boxing" and "unboxing" of Integer
objects in their solutions, which eliminates the need to use "new Integer(...)" in part (a) and
"intValue()" in part (b).

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.

© 2017 The College Board.


Visit the College Board on the Web: www.collegeboard.org.
AP® COMPUTER SCIENCE A
2017 SCORING GUIDELINES

Question 2: MultPractice

Class: MultPractice 9 points


Intent: Define implementation of class to produce multiplication practice problems

+1 Declares header: public class MultPractice implements StudyPractice

+1 Declares all necessary private instance variables

+2 Constructor

+1 Declares header: public MultPractice(int __, int __)

+1 Initializes all instance variables using parameters

+3 getProblem method

+1 Declares header: public String getProblem()

+1 Builds string with current values of instance variables

+1 Returns constructed string

+2 nextProblem method

+1 Declares header: public void nextProblem()

+1 Updates instance variable(s) to reflect incremented second number

© 2017 The College Board.


Visit the College Board on the Web: www.collegeboard.org.
AP® COMPUTER SCIENCE A
2017 SCORING GUIDELINES

Question 2: Scoring Notes

Class MultPractice 9 points


Points Rubric Criteria Responses earn the point if they ... Responses will not earn the point if they ...
Declares header: • omit keyword public • declare class private
public class
+1 MultPractice
implements
StudyPractice
Declares all necessary • declare the unchanging • declare variables as static
+1 private instance instance variable as final • omit keyword private
variables
+2 Constructor
Declares header: • omit keyword public
public
+1 MultPractice
(int ___, int ___)
• fail to declare nonlocal variables
Initializes all instance
• initialize local variables instead of
+1 variables using
instance variables
parameters
• assign variables to parameters
+3 getProblem method
Declares header: • fail to declare method public
+1 public String
getProblem()
• write appropriate code in a • fail to declare nonlocal variables
Builds string with method other than
• fail to use instance variables
+1 current values of getProblem
instance variables • miscast (String) intVar
• make capitalization or spacing
errors • call intVar.toString()
Returns constructed • return a literal string
+1
string
+2 nextProblem method
Declares header: • fail to declare method public
+1 public void
nextProblem()
Updates instance • fail to declare non-local variables
variable(s) to reflect
+1 incremented second
number

© 2017 The College Board.


Visit the College Board on the Web: www.collegeboard.org.
AP® COMPUTER SCIENCE A
2017 SCORING GUIDELINES

Question 2: MultPractice

public class MultPractice implements StudyPractice


{
private int first;
private int second;

public MultPractice(int num1, int num2)


{
first = num1;
second = num2;
}

public String getProblem()


{
return first + " TIMES " + second;
}

public void nextProblem()


{
second++;
}
}

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.

© 2017 The College Board.


Visit the College Board on the Web: www.collegeboard.org.
AP® COMPUTER SCIENCE A
2017 SCORING GUIDELINES

Question 3: PhraseEditor

Part (a) replaceNthOccurrence 5 points


Intent: Replace the nth occurrence of a given string with a given replacement

+1 Calls findNthOccurrence to find the index of the nth occurrence

+1 Preserves currentPhrase only if nth occurrence does not exist

+1 Identifies components of currentPhrase to retain (uses substring to extract before/after)

+1 Creates replacement string using identified components and repl

+1 Assigns replacement string to instance variable (currentPhrase)

Part (b) findLastOccurrence 4 points


Intent: Return the index of the last occurrence of a given string

+1 Calls findNthOccurrence to find the index of the nth occurrence

+1 Increments (or decrements) the value used as n when finding nth occurrence

+1 Returns the index of the last occurrence, if it exists

+1 Returns -1 only when no occurrences exist

Question-Specific Penalties

-1 (q) Uses currentPhrase.findNthOccurrence

-2 (r) Confused identifier instead of currentPhrase

© 2017 The College Board.


Visit the College Board on the Web: www.collegeboard.org.
AP® COMPUTER SCIENCE A
2017 SCORING GUIDELINES

Question 3: Scoring Notes

Part (a) replaceNthOccurrence 5 points


Points Rubric Criteria Responses earn the point if they ... Responses will not earn the point if they ...
Calls • do not use the result of calling
findNthOccurrence findNthOccurrence
+1
to find the index of the
nth occurrence
Preserves • fail to use a conditional
currentPhrase only
+1
if nth occurrence does
not exist
Identifies components of • identify start and end of substring
currentPhrase to to be replaced
+1 retain (uses
substring to extract
before/after)
Creates replacement • create a replacement string that is out
+1 string using identified of order
components and repl
Assigns replacement
string to instance
+1
variable
(currentPhrase)
Part (b) findLastOccurrence 4 points
Points Rubric Criteria Responses earn the point if they ... Responses will not earn the point if they ...
Calls • do not use the result of calling • return
findNthOccurrence findNthOccurrence currentPhrase.lastIndexOf(str);
+1 • call findNthOccurrence with an
to find the index of the
nth occurrence integer parameter of 0
• return
Increments (or currentPhrase.lastIndexOf(str);
decrements) the value • advance through
+1 currentPhrase searching for
used as n when finding
nth occurrence nth occurrence of str

• return • shorten string being searched


currentPhrase.lastIndexOf(str); • always return in first iteration of the
Returns the index of the • compute the correct value to be
+1 last occurrence, if it loop
returned in all cases, but no return
exists statement exists for any case

• return • compute the correct value to be


currentPhrase.lastIndexOf(str); returned in all cases, but no return
Returns -1 only when no statement exists for any case
+1
occurrences exist • always return in first iteration of the
loop

© 2017 The College Board.


Visit the College Board on the Web: www.collegeboard.org.
AP® COMPUTER SCIENCE A
2017 SCORING GUIDELINES

Question 3: PhraseEditor

Part (a)

public void replaceNthOccurrence(String str, int n, String repl)


{
int loc = findNthOccurrence(str, n);

if (loc != -1)
{
currentPhrase = currentPhrase.substring(0, loc) + repl +
currentPhrase.substring(loc + str.length());
}
}

Part (b)

public int findLastOccurrence(String str)


{
int n = 1;
while (findNthOccurrence(str, n+1) != -1)
{
n++;
}
return findNthOccurrence(str, n);
}

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.

© 2017 The College Board.


Visit the College Board on the Web: www.collegeboard.org.
AP® COMPUTER SCIENCE A
2017 SCORING GUIDELINES

Question 4: Successor Array

Part (a) findPosition 5 points


Intent: Find the position of a given integer in a 2D integer array

+1 Accesses all necessary elements of intArr (no bounds errors)

+1 Identifies intArr element equal to num (in context of an intArr traversal)

+1 Constructs Position object with same row and column as identified intArr element

+1 Selects constructed object when intArr element identified; null when not

+1 Returns selected value

Part (b) getSuccessorArray 4 points


Intent: Create a successor array based on a 2D integer array

+1 Creates 2D array of Position objects with same dimensions as intArr

+1 Assigns a value to a location in 2D successor array using a valid call to findPosition

+1 Determines the successor Position of an intArr element accessed by row and column
(in context of intArr traversal)

+1 Assigns all necessary locations in successor array with corresponding position object or null
(no bounds errors)

Question-Specific Penalties

-1 (s) Uses confused identifier Arr

-1 (t) Uses intArr[].length as the number of columns

-1 (u) Uses non-existent accessor methods from Position

© 2017 The College Board.


Visit the College Board on the Web: www.collegeboard.org.
AP® COMPUTER SCIENCE A
2017 SCORING GUIDELINES

Question 4: Scoring Notes

Part (a) findPosition 5 points


Points Rubric Criteria Responses earn the point if they ... Responses will not earn the point if they ...
Accesses all • use if (...) return;
necessary else return null; inside loop
+1 elements of • confuse row and column bounds
intArr (no
bounds errors) • fail to traverse intArr
Identifies intArr • use .equals instead of ==
element equal to
+1 num (in context of
an intArr
traversal)
Constructs • omit keyword new
Position object • use (r,c) instead of
with same row and Position(r,c)
+1 column as
identified intArr
element
Selects constructed • use "null" instead of null • use if (...) return;
object when • construct a String object using else return null; inside loop
+1 intArr element row and column indices • use (r,c) instead of
identified; null
Position(r,c)
when not
Returns selected
+1 value
Part (b) getSuccessorArray 4 points
Points Rubric Criteria Responses earn the point if they ... Responses will not earn the point if they ...
Creates 2D array of • omit keyword new
Position objects
+1 with same
dimensions as
intArr
Assigns a value to a • call • reimplement the code from
location in 2D Successors.findPosition(…) findPosition
+1 successor array • call findPosition with a single
using a valid call to argument
findPosition • call this.findPosition(…)
Determines the • reimplement the code from • call findPosition using an
successor findPosition integer that is not identified with a
Position of an location in intArr
intArr element
+1 • call findPosition with a single
accessed by row
and column (in argument
context of intArr
traversal)
Assigns all • use SuccessorArray dimensions • reimplement the code from
necessary locations correctly, even if SuccessorArray findPosition but mishandle the
in successor array was not initialized properly null case.
+1 with corresponding
• fail to traverse intArr
position object or
• only assign non-null entries to
null (no bounds
SuccessorArray
errors)

Return is not assessed in Part (b).

© 2017 The College Board.


Visit the College Board on the Web: www.collegeboard.org.
AP® COMPUTER SCIENCE A
2017 SCORING GUIDELINES

Question 4: Successor Array

Part (a)

public static Position findPosition(int num, int[][] intArr)


{
for (int row=0; row < intArr.length; row++)
{
for (int col=0; col < intArr[0].length; col++)
{
if (intArr[row][col] == num)
{
return new Position(row, col);
}
}
}
return null;
}

Part (b)

public static Position[][] getSuccessorArray(int[][] intArr)


{
Position[][] newArr = new Position[intArr.length][intArr[0].length];

for (int row=0; row < intArr.length; row++)


{
for (int col=0; col < intArr[0].length; col++)
{
newArr[row][col] = findPosition(intArr[row][col]+1, intArr);
}
}
return newArr;
}

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.

© 2017 The College Board.


Visit the College Board on the Web: www.collegeboard.org.

You might also like