AP COMPUTER SCIENCE AB 2006 SCORING GUIDELINES

Similar documents
AP COMPUTER SCIENCE A 2010 GENERAL SCORING GUIDELINES

AP COMPUTER SCIENCE A 2006 SCORING GUIDELINES

AP Computer Science A

AP Computer Science A

AP Computer Science A

AP Computer Science A

AP Computer Science A 2003 Scoring Guidelines

Student Performance Q&A:

AP COMPUTER SCIENCE AB 2008 SCORING GUIDELINES

AP COMPUTER SCIENCE AB 2007 SCORING GUIDELINES

Objects and Iterators

Chief Reader Report on Student Responses:

AP Computer Science A 2004 Scoring Commentary

Introduction to Programming Using Java (98-388)

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

AP PHYSICS B 2009 SCORING GUIDELINES

Student Performance Q&A:

CS61BL Summer 2013 Midterm 2

Inheritance and Polymorphism. CS180 Fall 2007

Java for Non Majors. Final Study Guide. April 26, You will have an opportunity to earn 20 extra credit points.

APCS Semester #1 Final Exam Practice Problems

TeenCoder : Java Programming (ISBN )

Inheritance and Interfaces

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

AP PHYSICS B 2014 SCORING GUIDELINES

Student Performance Q&A:

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

AP COMPUTER SCIENCE A 2009 SCORING GUIDELINES

Instantiation of Template class

AP Physics 2: Algebra-Based

Do not start the test until instructed to do so!

Review Ch 5 static Multiple Choice Test Creating Class Methods

AP Computer Science AB 2005 Scoring Guidelines

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

Problem Solving with C++

Absolute C++ Walter Savitch

Chapter 4 Defining Classes I

CSE 142 Wi04 Midterm 2 Sample Solution Page 1 of 8

STUDENT LESSON A20 Inheritance, Polymorphism, and Abstract Classes

Java Object Oriented Design. CSC207 Fall 2014

AP Computer Science Chapter 10 Implementing and Using Classes Study Guide

CS 61B (Clancy, Yelick) Solutions and grading standards for exam 2 Spring 2001 Exam information

APCS Unit 5 Exam. Assuming all four classes have a default constructor, which of the following statements would result in an error from the compiler?

// constructor: takes a String as parameter and creates a public Cat (String x) { name = x; age = 0; lives = 9; // cats start out with 9 lives }

Module Contact: Dr Geoff McKeown, CMP Copyright of the University of East Anglia Version 2

Intro to OOP Visibility/protection levels and constructors Friend, convert constructor, destructor Operator overloading a<=b a.

AP COMPUTER SCIENCE A 2008 SCORING GUIDELINES

CS 142 Style Guide Grading and Details

CompuScholar, Inc. 9th - 12th grades

Use the scantron sheet to enter the answer to questions (pages 1-6)

Solution to Test of Computer Science 203x Level Score: / 100 Time: 100 Minutes

UNIT 3 ARRAYS, RECURSION, AND COMPLEXITY CHAPTER 11 CLASSES CONTINUED

ECE 122. Engineering Problem Solving with Java

Chapter 6 Introduction to Defining Classes

Outline. A C++ Linked Structure Class A C++ Linked List C++ Linked Dynamic Memory Errors In-class work. 1 Chapter 11: C++ Linked Structures

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

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

C# Language. CSE 409 Advanced Internet Technology

CS 251 Intermediate Programming Inheritance

CS445 Week 9: Lecture

Weiss Chapter 1 terminology (parenthesized numbers are page numbers)

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


Java Primer 1: Types, Classes and Operators

JAVA MOCK TEST JAVA MOCK TEST II

Argument Passing All primitive data types (int etc.) are passed by value and all reference types (arrays, strings, objects) are used through refs.

Java Fall 2018 Margaret Reid-Miller

This project is worth 600 points Due on April 17 Pick one from the following project to create complete running program with documentation

CMPS 134: Computer Science I Fall 2011 Test #1 October 5 Name Dr. McCloskey

CSI33 Data Structures

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

QUEEN MARY, UNIVERSITY OF LONDON DCS128 ALGORITHMS AND DATA STRUCTURES Class Test Monday 27 th March

CS304 Object Oriented Programming Final Term

CS 314 Final Fall 2012

CSE 431S Type Checking. Washington University Spring 2013

Lesson 10A OOP Fundamentals. By John B. Owen All rights reserved 2011, revised 2014

A Java Execution Simulator

Practice Questions for Final Exam: Advanced Java Concepts + Additional Questions from Earlier Parts of the Course

CS1083 Week 2: Arrays, ArrayList

Computer Science II (20073) Week 1: Review and Inheritance

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

Introduction to Computer Science Midterm 3 Fall, Points

Ticket Machine Project(s)

CIS 162 Project 4 Farkle (a dice game)

Programming II (CS300)

Java 1996 AP Computer Science Question 3

Advanced Programming - JAVA Lecture 4 OOP Concepts in JAVA PART II

More about inheritance

CSI33 Data Structures

CSCI 1301: Introduction to Computing and Programming Summer 2018 Lab 07 Classes and Methods

Graphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub

CS 314 Final Fall 2011

ENCAPSULATION AND POLYMORPHISM

CSE 143, Winter 2010 Final Exam Thursday, March 18, 2010

Quiz1 Fall 2007 October 2 nd, UNIVERSITY OF WINDSOR Fall 2007 QUIZ # 1 Solution. Examiner:Ritu Chaturvedi Dated :October 2nd, 2007.

IMACS: AP Computer Science A

Implements vs. Extends When Defining a Class

Subclass Gist Example: Chess Super Keyword Shadowing Overriding Why? L10 - Polymorphism and Abstract Classes The Four Principles of Object Oriented

An Introduction to C++

CS Programming I: Inheritance

Transcription:

AP COMPUTER SCIENCE AB 2006 SCORING GUIDELINES Question 2: Packs & Bundles (Design) Part A: Pack 3 1/2 points +1/2 class Pack implements Product +1/2 declare both private fields (int and Product) +1 constructor +1/2 public Pack(int?, Product?) (Item OK if matches field) +1/2 initialize fields +1 1/2 getprice +1/2 public double getprice() +1/2 access product s current price and pack s current number lose if don t call +1/2 calculate and return price getprice on a product Part B: Bundle 5 1/2 points +1/2 class Bundle implements Product +1/2 private collection field +1 constructor (if collection is initialized when declared, no constructor is needed) +1/2 public Bundle() +1/2 initialize collection +1 add +1/2 public void add(product?) (No penalty if returns reasonable value) +1/2 add parameter to collection +2 1/2 getprice +1/2 public double getprice() +1/2 declare & initialize sum (must be added to) +1/2 loop over every element in collection lose if accum. +1/2 sum is updated with getprice for each element price in add() +1/2 return sum Common Usage: -1 for extraneous code with compile-time errors -1/2 missing public on getprice 2006 The College Board. All rights reserved. 3

AP COMPUTER SCIENCE A/AB 2006 GENERAL USAGE Most common usage errors are addressed specifically in rubrics with points deducted in a manner other than indicated on this sheet. The rubric takes precedence. Usage points can only be deducted if the part where it occurs has earned credit. A usage error that occurs once when the same usage is correct two or more times can be regarded as an oversight and not penalized. If the usage error is the only instance, one of two, or occurs two or more times, then it should be penalized. A particular usage error should be penalized only once in a problem, even if it occurs on different parts of a problem. Nonpenalized Errors Minor Errors (1/2 point) Major Errors (1 point) spelling/case discrepancies* local variable not declared when any other variables are declared in some part default constructor called without parens; for example, new Fish; use keyword as identifier [r,c], (r)(c)or(r,c)instead of [r][c] = instead of == (and vice versa) length/size confusion for array, String, and ArrayList, with or without () private qualifier on local variable extraneous code with no side-effect, for example a check for precondition common mathematical symbols for operators (x < > < > ) missing where indentation clearly conveys intent missing ( ) on method call or around if/while conditions missing ;s missing new for constructor call once, when others are present in some part confused identifier (e.g., len for length or left() for getleft() ) no local variables declared new never used for constructor calls void method or constructor returns a value modifying a constant (final) use equals or compareto method on primitives, for example int x; x.equals(val) [] get confusion if access not tested in rubric assignment dyslexia, for example, x + 3 = y; for y = x + 3; super(method()) instead of super.method() formal parameter syntax (with type) in method call, e.g., a = method(int x) missing public from method header when required "false"/"true" or 0/1 for boolean values "null" for null extraneous code which causes side-effect, for example, information written to output use interface or class name instead of variable identifier, for example Simulation.step() instead of sim.step() amethod(obj) instead of obj.amethod() use of object reference that is incorrect, for example, use of f.move() inside method of Fish class use private data or method when not accessible destruction of data structure (e.g., by using root reference to a TreeNode for traversal of the tree) use class name in place of super either in constructor or in method call missing downcast from collection missing int cast when needed missing public on class or constructor header *Note: Spelling and case discrepancies for identifiers fall under the "nonpenalized" category as long as the correction can be unambiguously inferred from context. For example, "Queu" instead of "Queue". Likewise, if a student declares "Fish fish;", then uses Fish.move() instead of fish.move(), the context allows for the reader to assume the object instead of the class.

AP COMPUTER SCIENCE AB 2006 CANONICAL SOLUTIONS Question 2: Packs & Bundles (Design) PART A: public class Pack implements Product private int numproducts; private Product prod; public Pack(int num, Product p) numproducts = num; prod = p; public double getprice() return prod.getprice() * numproducts; PART B: public class Bundle implements Product private ArrayList productlist; public Bundle() productlist = new ArrayList(); public void add(product newprod) productlist.add(newprod); public double getprice() double totalcost = 0.0; for (int i = 0; i < productlist.size(); i++) totalcost += ((Product)productList.get(i)).getPrice(); return totalcost; 2006 The College Board. All rights reserved.

AP COMPUTER SCIENCE AB 2006 SCORING COMMENTARY Question 2 Overview This question focused on students ability to design a hierarchy of classes using inheritance. A Product interface was provided, along with an Item class that implemented the interface. The Item class contained private data fields for storing a product description and a unit price, a constructor for initializing the fields, accessor methods for retrieving the description and unit price, and a mutator method for changing the price. In part (a) students were required to design and implement the Pack class, which also implemented the Product interface. A Pack could store an arbitrary quantity of a Product and so needed private fields for the Product and its quantity. The class also required a constructor (to initialize the fields) and the getprice method (to calculate the price of the Pack by multiplying the Product price by its quantity). In part (b) students were required to design and implement a Bundle class, which also implemented the Item interface. A Bundle could store an arbitrary collection of Products and so needed a private field for the collection. The class also required a constructor (to initialize the field), the getprice method (to iterate through the collection and calculate the total cost of all Products), and an add method (to add a new Product to the collection). In addition to testing whether the students could design and implement classes from scratch, this question measured their understanding of polymorphism. Each class implemented the Product interface and contained fields of type Product, which allowed for arbitrary structures such as Bundles of Bundles containing Packs of Bundles. Sample: AB2A Score: 8 This response earned almost all the points in part (a). The only deduction was a ½ point for declaring itemtype as an Item rather than a Product. Since the constructor header is consistent with this declaration, the student earned the ½ point for the constructor header. The getprice method earned all three ½ points. The extraneous method getdescription is also consistent with the student s use of Item and was not penalized. In part (b) the solution is very similar to the canonical solution. There was a ½ point deduction, however, for not declaring the ArrayList items as a private field. Sample: AB2B Score: 6 The Pack class correctly implements Product, earning the first ½ point from the scoring guidelines. None of the fields are declared to be private, so the second ½ point was lost. Because the constructor is missing parameter types, the student lost the first ½ point for the constructor. The initializations are correct, earning the second ½ point for the constructor. The header for getprice is missing the public qualifier, so while the first ½ point of getprice was earned, a ½ point was deducted for usage (since the header does not explicitly follow the interface). The body of the method is correct, earning the last two ½ points. The Bundle class does not implement Product, so the first ½ point on part (b) was deducted. As in part (a) the student does not make the collection field private, and so the second ½ point was lost here as well. The constructor and add methods are correct (the lack of the public qualifier on either was counted as unpenalized usage). The getprice method is also missing public contradicting the interface, but since usage for this error was deducted on part (a), it was not deducted again in part (b). The ½ point for the getprice header was given. There is no initialization of total_price, costing that ½ point. The remaining three ½ points were awarded. 2006 The College Board. All rights reserved.

AP COMPUTER SCIENCE AB 2006 SCORING COMMENTARY Question 2 (continued) Sample: AB2C Score: 3 The header for the class Pack is correct. The variable myitem is declared as an Item rather than as a Product, losing the second ½ point. However, since Item is used consistently in the constructor, the student earned the ½ point for the constructor header. The initializations correctly assign the parameters to the fields. The header for getprice is correct and matches the interface. The last two ½ points of the getprice scoring guidelines were not awarded since getprice is never called on a product. The header for the Bundle class is also correct, earning the first ½ point from the part (b) scoring guidelines. The only other ½ point was earned for the correct header for the default constructor. No collection is declared or initialized. The add and getprice methods do not have a return type. There is no variable to which prices taken from Product objects are added and no loop over a collection, so no points were given for the getprice method. 2006 The College Board. All rights reserved.