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

Chief Reader Report on Student Responses:

AP COMPUTER SCIENCE AB 2006 SCORING GUIDELINES

AP COMPUTER SCIENCE A 2006 SCORING GUIDELINES

Student Performance Q&A:

AP Computer Science A 2003 Scoring Guidelines

Visit us at

Student Performance Q&A:

Introduction to Programming Using Java (98-388)

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

APCS Semester #1 Final Exam Practice Problems

ECE 122. Engineering Problem Solving with Java

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

AP Computer Science AB 2005 Scoring Guidelines

Full file at

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

TeenCoder : Java Programming (ISBN )

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

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

1 Lexical Considerations

AP Computer Science A 2004 Scoring Commentary

CSC Java Programming, Fall Java Data Types and Control Constructs

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

Control Flow. COMS W1007 Introduction to Computer Science. Christopher Conway 3 June 2003

Objects and Iterators

CSc 10200! Introduction to Computing. Lecture 2-3 Edgardo Molina Fall 2013 City College of New York

Array. Prepared By - Rifat Shahriyar

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS

Student Performance Q&A:

Absolute C++ Walter Savitch

AP COMPUTER SCIENCE AB 2008 SCORING GUIDELINES

L o o p s. for(initializing expression; control expression; step expression) { one or more statements }

CS313D: ADVANCED PROGRAMMING LANGUAGE

CSI33 Data Structures

Weiss Chapter 1 terminology (parenthesized numbers are page numbers)

AP Computer Science AB 2007 Free-Response Questions

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

FORM 2 (Please put your name and form # on the scantron!!!!)

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

Computer Sciences 302 Exam 2 Information & Sample Exam

Final Exam CS 152, Computer Programming Fundamentals December 9, 2016

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

JAVA REVIEW cs2420 Introduction to Algorithms and Data Structures Spring 2015

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

1. Answer as shown or -2 unless question allows partial credit. No points off for differences in spacing, capitalization, commas, and braces

Problem Solving with C++

Operators and Expressions


CS 3114 Data Structures and Algorithms DRAFT Project 2: BST Generic

Introduction to Computer Science Midterm 3 Fall, Points

CS 112 Introduction to Computing II. Wayne Snyder Computer Science Department Boston University

Java Fall 2018 Margaret Reid-Miller

CS 142 Style Guide Grading and Details

CS 314 Midterm 2 Fall 2012

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

Looping. Arizona State University 1

CS111: PROGRAMMING LANGUAGE II

AP Physics 2: Algebra-Based


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

Student Performance Q&A:

CS111: PROGRAMMING LANGUAGE II

CS 251 Intermediate Programming Methods and Classes

SOAPScript For squeaky-clean code, use SOAPScript Language Summary Bob Nisco Version 0.5 β

Introduction to Visual Basic and Visual C++ Arithmetic Expression. Arithmetic Expression. Using Arithmetic Expression. Lesson 4.

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

COMP 202 Recursion. CONTENTS: Recursion. COMP Recursion 1

CSI33 Data Structures

G Programming Languages - Fall 2012

IPCoreL. Phillip Duane Douglas, Jr. 11/3/2010

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

Welcome Back. CSCI 262 Data Structures. Hello, Let s Review. Hello, Let s Review. How to Review 8/19/ Review. Here s a simple C++ program:

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

AP COMPUTER SCIENCE AB 2007 SCORING GUIDELINES

Multiple Choice (Questions 1 14) 28 Points Select all correct answers (multiple correct answers are possible)

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

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

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

Language Features. 1. The primitive types int, double, and boolean are part of the AP

Lecture 10 Declarations and Scope

Inheritance and Interfaces

Java Primer 1: Types, Classes and Operators

ECE 122. Engineering Problem Solving with Java

UNIT- 3 Introduction to C++

SECTION II: LANGUAGE BASICS

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

PIC 20A The Basics of Java

PROGRAMMING FUNDAMENTALS

Chapter 5: Prefix vs. Postfix 8/19/2018. The Increment and Decrement Operators. Increment and Decrement Operators in Program 5-1

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

Index COPYRIGHTED MATERIAL

Pace University. Fundamental Concepts of CS121 1

1. Expressions - 1 point each. -1 for missing or extra " OR.0. differences in capitalization of true and false okay. No limit on points off.

CS 1331 Exam 1. Fall Failure to properly fill in the information on this page will result in a deduction of up to 5 points from your exam score.

CS313D: ADVANCED PROGRAMMING LANGUAGE

CS 251 Intermediate Programming Methods and More

Java Foundations Certified Junior Associate

Transcription:

2017 AP Computer Science A Scoring Guidelines 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

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.

Question 1: Digits Part (a) Digits constructor 5 points Intent: Initialize instance variable using passed parameter Constructs digitlist Identifies a digit in num Adds at least one identified digit to a list Adds all identified digits to a list (must be in context of a loop) 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 Compares at least one identified consecutive pair of digitlist elements Determines if a consecutive pair of digitlist is out of order (must be in context of a digitlist traversal) Compares all necessary consecutive pairs of elements (no bounds errors) 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

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

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

Question 2: MultPractice Class: MultPractice 9 points Intent: Define implementation of class to produce multiplication practice problems Declares header: public class MultPractice implements StudyPractice Declares all necessary private instance variables +2 Constructor Declares header: public MultPractice(int, int ) Initializes all instance variables using parameters +3 getproblem method Declares header: public String getproblem() Builds string with current values of instance variables Returns constructed string +2 nextproblem method Declares header: public void nextproblem() Updates instance variable(s) to reflect incremented second number

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

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.

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

Part (a) replacenthoccurrence AP COMPUTER SCIENCE A 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

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.

Question 4: Successor Array Part (a) findposition 5 points Intent: Find the position of a given integer in a 2D integer array Accesses all necessary elements of intarr (no bounds errors) Identifies intarr element equal to num (in context of an intarr traversal) Constructs Position object with same row and column as identified intarr element Selects constructed object when intarr element identified; null when not Returns selected value Part (b) getsuccessorarray 4 points Intent: Create a successor array based on a 2D integer array Creates 2D array of Position objects with same dimensions as intarr Assigns a value to a location in 2D successor array using a valid call to findposition Determines the successor Position of an intarr element accessed by row and column (in context of intarr traversal) 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

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

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], 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.