AP Computer Science A

Similar documents
AP Computer Science A

AP Computer Science A

AP Computer Science A

AP COMPUTER SCIENCE A 2010 GENERAL SCORING GUIDELINES

AP COMPUTER SCIENCE AB 2006 SCORING GUIDELINES

AP COMPUTER SCIENCE A 2006 SCORING GUIDELINES

Chief Reader Report on Student Responses:

Student Performance Q&A:

AP Computer Science A 2003 Scoring Guidelines

Results from!the!2011 AP!Computer!Science A Exam Administration

AP Computer Science A 2004 Scoring Commentary

AP Physics 2: Algebra-Based

Student Performance Q&A:

AP COMPUTER SCIENCE AB 2008 SCORING GUIDELINES

calling a function - function-name(argument list); y = square ( z ); include parentheses even if parameter list is empty!

AP Computer Science A

AP Computer Science Principles

Account joeacct = new Account (100, new Account (500)); Account joeacct = new Account (100, new Account (500, null));

AP Computer Science AB 2005 Scoring Guidelines

AP COMPUTER SCIENCE AB 2007 SCORING GUIDELINES

AP Computer Science A 2013 Free-Response Questions

Note that if both p1 and p2 are null, equals returns true.

CS 170 Exam 2. Version: A Fall Name (as in OPUS) (print): Instructions:

AP PHYSICS B 2014 SCORING GUIDELINES

AP Computer Science AB 2007 Free-Response Questions

Cmpt 135 Assignment 2: Solutions and Marking Rubric Feb 22 nd 2016 Due: Mar 4th 11:59pm

APCS Semester #1 Final Exam Practice Problems

Makefiles Makefiles should begin with a comment section of the following form and with the following information filled in:

Student Performance Q&A:

ECE 122. Engineering Problem Solving with Java

Regis University CC&IS CS362 Data Structures

TeenCoder : Java Programming (ISBN )

Student Performance Q&A:

Example Candidate Responses. Cambridge International AS & A Level Computer Science. Paper 2

Object-Oriented Programming (OOP) Basics. CSCI 161 Introduction to Programming I

CpSc 1111 Lab 5 Formatting and Flow Control

One of Mike s early tests cases involved the following code, which produced the error message about something being really wrong:

AP PHYSICS B 2009 SCORING GUIDELINES

Course Text. Course Description. Course Objectives. StraighterLine Introduction to Programming in C++

CS 142 Style Guide Grading and Details

CS 2505 Computer Organization I Test 1. Do not start the test until instructed to do so! printed

CS 2505 Computer Organization I Test 1. Do not start the test until instructed to do so! printed

8*4 + 4 = 36 each int is 4 bytes

The Program Specification:

AP COMPUTER SCIENCE A 2008 SCORING GUIDELINES


University of Massachusetts Lowell

gcc o driver std=c99 -Wall driver.c bigmesa.c

C++ (Non for C Programmer) (BT307) 40 Hours

Creating a String Data Type in C

1 Lexical Considerations

Student Performance Q&A:

Note: This is a miniassignment and the grading is automated. If you do not submit it correctly, you will receive at most half credit.

COMP 202 Recursion. CONTENTS: Recursion. COMP Recursion 1

Prelim 2. CS 2110, November 20, 2014, 7:30 PM Extra Total Question True/False Short Answer

AP CALCULUS BC 2013 SCORING GUIDELINES

Chapter 10 Introduction to Classes

Assoc. Prof. Dr. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.

COMP-202. Recursion. COMP Recursion, 2011 Jörg Kienzle and others

Introduction to Computer Science Midterm 3 Fall, Points

Computer Science E-119 Fall Problem Set 1. Due before lecture on Wednesday, September 26

AP COMPUTER SCIENCE A 2009 SCORING GUIDELINES

Lecture 14 CSE11 Fall 2013 For loops, Do While, Break, Continue

Weiss Chapter 1 terminology (parenthesized numbers are page numbers)

CpSc 1011 Lab 4 Formatting and Flow Control Windchill Temps

CS-140 Fall 2017 Test 1 Version Practice Practie for Sept. 27, Name:

Lexical Considerations

Lecture 10 Declarations and Scope

Introduction to Programming (Java) 4/12

Inheritance and Interfaces

Java Foundations Certified Junior Associate

Computer Science 62. Bruce/Mawhorter Fall 16. Midterm Examination. October 5, Question Points Score TOTAL 52 SOLUTIONS. Your name (Please print)

Review Chapters 1 to 4. Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013

3D Graphics Programming Mira Costa High School - Class Syllabus,

CS 112 Programming 2. Lecture 10. Abstract Classes & Interfaces (1) Chapter 13 Abstract Classes and Interfaces

Synchronization SPL/2010 SPL/20 1

Chapter 4: Writing Classes

Program Development. Java Program Statements. Design. Requirements. Testing. Implementation

5/23/2015. Core Java Syllabus. VikRam ShaRma

Content-Based Assessments. Project 3H Hospital Materials

CS111: PROGRAMMING LANGUAGE II

Chapter 5. Repetition. Contents. Introduction. Three Types of Program Control. Two Types of Repetition. Three Syntax Structures for Looping in C++

CS 312 Midterm 2 Fall 2013

Math Released Item Grade 7. Grid Coordinates of a Square VH225469

2.8. Decision Making: Equality and Relational Operators

CS-140 Fall 2017 Test 1 Version Practice Practie for Sept. 27, Name:

Java Primer 1: Types, Classes and Operators

Do not start the test until instructed to do so!

UNIVERSITY OF TORONTO Faculty of Arts and Science

Computer Programming C++ (wg) CCOs

Cambridge Assessment International Education Cambridge International Advanced Subsidiary and Advanced Level. Published

CS/ECE 374 Fall Homework 1. Due Tuesday, September 6, 2016 at 8pm

Introduction to Programming Using Java (98-388)

Objects and Iterators

SCHOOL OF COMPUTING, ENGINEERING AND MATHEMATICS SEMESTER 1 EXAMINATIONS 2015/2016 CI101 / CI177. Programming

Looping. Arizona State University 1

CS111: PROGRAMMING LANGUAGE II

AP SEMINAR 2015 SCORING GUIDELINES

CS313D: ADVANCED PROGRAMMING LANGUAGE. Lecture 3: C# language basics II

Jim Lambers ENERGY 211 / CME 211 Autumn Quarter Programming Project 2

Transcription:

2017 AP Computer Science A Sample Student Responses and Scoring Commentary Inside: RR Free Response Question 3 RR Scoring Guideline RR Student Samples RR Scoring Commentary 2017 The College Board. College Board, Advanced Placement Program, AP, AP Central, and the acorn logo are registered trademarks of the College Board. 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 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. 2017 The College Board.

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 Calls findnthoccurrence to find the index of the nth occurrence Preserves currentphrase only if nth occurrence does not exist Identifies components of currentphrase to retain (uses substring to extract before/after) Creates replacement string using identified components and repl Assigns replacement string to instance variable (currentphrase) Part (b) findlastoccurrence 4 points Intent: Return the index of the last occurrence of a given string Calls findnthoccurrence to find the index of the nth occurrence Increments (or decrements) the value used as n when finding nth occurrence Returns the index of the last occurrence, if it exists 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.

Part (a) replacenthoccurrence AP COMPUTER SCIENCE A 2017 SCORING GUIDELINES Question 3: Scoring Notes 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 to find the index of the nth occurrence Preserves fail to use a conditional currentphrase only if nth occurrence does not exist Identifies components of currentphrase to retain (uses substring to extract before/after) Creates replacement string using identified components and repl Assigns replacement string to instance variable (currentphrase) Part (b) findlastoccurrence identify start and end of substring to be replaced create a replacement string that is out of order 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); to find the index of the call findnthoccurrence with an nth occurrence integer parameter of 0 Increments (or decrements) the value used as n when finding nth occurrence return currentphrase.lastindexof(str); advance through currentphrase searching for nth occurrence of str Returns the index of the last occurrence, if it exists return currentphrase.lastindexof(str); compute the correct value to be returned in all cases, but no return statement exists for any case shorten string being searched always return in first iteration of the loop Returns -1 only when no occurrences exist return currentphrase.lastindexof(str); compute the correct value to be returned in all cases, but no return statement exists for any case always return in first iteration of the loop 2017 The College Board.

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) { 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.

2017 The College Board.

2017 The College Board.

2017 The College Board.

2017 The College Board.

2017 The College Board.

2017 The College Board.

AP COMPUTER SCIENCE A 2017 SCORING COMMENTARY Question 3 Overview This question tested the students ability to use String methods from the AP Java subset to perform processing of strings using various parameters and instance variables. The problem required students to use a provided helper method in their solutions. In part (a) students were asked to write a method to examine and potentially modify the instance variable currentphrase. Students were required to use the already-implemented findnthoccurrence helper method to replace the nth occurrence of a string in currentphrase if it was present the number of times specified by the parameter. The new string was created by identifying and extracting the substrings of currentphrase to retain, concatenating these strings with the replacement string parameter repl in the correct order, and assigning this value to currentphrase. In part (b) students were asked to write a method to find the index of the last occurrence of a specified string in currentphrase using the already-implemented findnthoccurrence helper method. In finding the last occurrence, student solutions need to be capable of examining currentphrase multiple times using either a call to findnthoccurrence or by reimplementing this functionality and examining various substrings while advancing through currentphrase. Students who used findnthoccurrence to examine currentphrase were required to demonstrate an understanding of iteration: setting the loop lower bound ensuring the precondition n > 0 is not violated in the findnthoccurrence call and setting the loop upper bound to allow findnthoccurrence to be called with an argument n equal to currentphrase.length. Students who reimplemented the findnthoccurrence functionality were also required to demonstrate an understanding of iteration. The loop bounds needed to be set to ensure that no bounds errors occurred in the matching of substrings to the string parameter. Regardless of the algorithm used to find the nth occurrence, students were required to return the correct index of the last occurrence, or return -1 if no occurrence was found. Sample: 3A Score: 9 In part (a) the response earned point 1 because findnthoccurrence is correctly called with the correct arguments. Point 2 was earned because the instance variable currentphrase is preserved only when the nth occurrence does not exist. The correct components of currentphrase to retain are identified, so point 3 was earned. The replacement string is correctly created, which earned point 4, and the replacement string is assigned to currentphrase, which earned point 5. Part (a) earned 5 points. In part (b) point 1 was earned by calling findnthoccurrence with the proper arguments that satisfy the precondition requiring n to be greater than zero. Point 2 was earned in the while loop when the int argument (n) used in the call to findnthoccurrence is incremented when attempting to find the next occurrence of str. While findnthoccurrence returns a value not equal to -1, the loop continues to search for the next occurrence. The loop terminates when findnthoccurrence(str, n) returns -1, with n storing the correct number of occurrences of str. If there is at least one occurrence of str, the solution correctly returns the index of the last occurrence using a call to findnthoccurrence(str, n), so point 3 was earned. If no occurrences of str exist, the response correctly returns -1 and earned point 4. Part (b) earned 4 points. 2017 The College Board.

AP COMPUTER SCIENCE A 2017 SCORING COMMENTARY Question 3 (continued) Sample: 3B Score: 6 In part (a) the response calls findnthoccurrence on currentphrase. The object currentphrase is not a Phrase object, so this is an incorrect method call. Because the response uses the same call currentphrase.findnthoccurrence(str, n) in parts (a) and (b), this response earned point 1 but a one-point question-specific penalty was deducted. This response preserves currentphrase if currentphrase does not contain n occurrences of str, so it earned point 2. The response identifies the correct components of currentphrase to retain, which earned point 3. The response creates the replacement string, using identified components and repl, and earned point 4. The response did not earn point 5 because currentphrase is not assigned the value of the replacement string. Part (a) earned 4 points, but a one-point question-specific penalty was deducted. In part (b) the response calls currentphrase.findnthoccurrence(str, n) with valid arguments and earned point 1 because the question-specific penalty was already deducted in part (a). Within the bounds of the for loop, the variable i is incremented and used in the call to findnthoccurrence, so point 2 was earned. This response did not earn point 3 because it fails to return the index of the last occurrence, if it exists, because the loop bounds only go until str.length, not currentphrase.length. Point 4 was earned because the response correctly returns -1 if no occurrences of str exist. Part (b) earned 3 points. Sample: 3C Score: 2 In part (a) this response's call to findnthoccurrence includes parameter type and did not earn point 1. Point 2 was earned because the return value from the call to findnthoccurrence is used to preserve currentphrase only if the nth occurrence does not exist. Point 3 was not earned as this response fails to identify the components of currentphrase to retain. Point 4 was not earned as no replacement string is created using the identified component and repl. Point 5 was not earned as the replacement string is not assigned to currentphrase. Part (a) earned 1 point. In part (b) point 1 was not earned as findnthoccurrence is called with int parameter equal to 0 in violation of the precondition. Point 2 was earned as the loop increments n, the variable used in the call to findnthoccurrence. The loop's upper bound is incorrect, so this response did not earn point 3. This response incorrectly returns 0 if no occurrences exist and did not earn point 4. Part (b) earned 1 point. 2017 The College Board.