Survey
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
APPENDIX A
AP Computer Science Java Subset
The AP Java subset is intended to outline the features of Java that may appear on the AP
Computer Science A Exam. The AP Java subset is NOT intended as an overall
prescription for computer science courses — the subset itself will need to be
supplemented in order to address all topics in a typical introductory curriculum. For
example, input and output must be part of a course on computer programming. However,
there are many ways to handle input and output in Java. Because of this variation, details
of input and output (except for basic text output using System.out.print and
System.out.println) are not tested on the AP Computer Science A Exam.
This appendix describes the Java subset that students will be expected to understand
when they take the AP Computer Science A Exam. A number of features are also
mentioned that are potentially relevant in an introductory computer science course but
are not tested on the exam. Omission of a feature from the AP Java subset does not
imply any judgment that the feature is inferior or not worthwhile.
The AP Java subset was selected to
1. enable the test designers to formulate meaningful questions.
2. help students with test preparation.
3. enable instructors to follow a variety of approaches in their courses.
To help students with test preparation, the AP Java subset was intentionally kept
small. Language constructs and library features were omitted that did not add
significant functionality and that can, for the formulation of exam questions, be
expressed by other mechanisms in the subset.
The AP Java subset gives instructors flexibility in how they use Java in their course.
For example, some courses teach how to perform input/output using streams or
readers/writers, others teach graphical user interface construction, and yet others rely
on a tool or library that handles input/output. For the purpose of the AP Computer
Science A Exam, these choices are incidental and are not central for the problem
solving process or for the mastery of computer science concepts. The AP Java subset
does not address handling of user input at all. That means that the subset is not
complete. To create actual programs, instructors need to present additional
mechanisms in their courses.
The following section contains the language features that may be tested on the AP
Computer Science A Exam. The Java Quick Reference contains a list specifying which
Standard Java classes, interfaces, constants, and methods may be used on the exam.
This document is available to students when they take the exam, is available at AP
Central, and is included in Appendix B.
© 2014 The College Board. Visit the College Board on the Web: www.collegeboard.org.
61
Language Features and other Testable Topics
Tested in the AP CS A Exam
Notes
Not tested in the AP CS A Exam,
but potentially relevant/useful
Comments
/* */, //, and /** */
Javadoc @param and @return
comment tags
Javadoc tool
Primitive Types
char, byte, short, long,
float
int,
double,
boolean
Operators
Arithmetic: +, −, *, /, %
Increment/Decrement: ++, −−
Assignment: =, +=, −=, *=,
1, 2, 3,
4, 5
/=, %=
Relational: ==, !=, <, <=,
>, >=
&, |, ^
(char), (float)
StringBuilder
Shift: <<, >>, >>>
Bitwise: ~, &, |, ^
Conditional: ?:
Logical: !, &&, ||
Numeric casts: (int), (double)
String concatenation: +
Object Comparison
object identity (==, !=) vs.
object equality (equals),
implementation of equals
String compareTo
Comparable
Escape Sequences
\", \\, \n inside strings
\’, \t, \unnnn
Input / Output
System.out.print,
System.out.println
6
Scanner, System.in,
System.out, System.err,
Stream input/output,
GUI input/output,
parsing input: Integer.parseInt,
Double.parseDouble
formatting output:
System.out.printf
62
© 2014 The College Board. Visit the College Board on the Web: www.collegeboard.org.
Tested in the AP CS A Exam
Notes
Not tested in the AP CS A Exam,
but potentially relevant/useful
Exceptions
try/catch/finally
throw, throws
assert
ArithmeticException,
NullPointerException,
IndexOutOfBoundsException,
ArrayIndexOutOfBoundsException,
IllegalArgumentException
Arrays
1-dimensional arrays,
2-dimensional rectangular arrays,
initializer list: { … },
row-major order of
2-dimensional array elements
7, 8
new type[]{ … } ,
ragged arrays (non-rectangular),
arrays with 3 or more dimensions
Control Statements
switch,
break, continue,
do-while
if, if/else,
while, for,
enhanced for (for-each),
return
Variables
parameter variables,
local variables,
private instance variables:
visibility (private)
static (class) variables:
visibility (public, private),
final parameter variables,
final local variables,
final instance variables
final
Methods
visibility (public, private),
static, non-static,
method signatures,
overloading, overriding,
parameter passing
9, 10
visibility (protected),
public static void
main(String[] args),
command line arguments,
variable number of parameters,
final
Constructors
11, 12
super(), super(args)
© 2014 The College Board. Visit the College Board on the Web: www.collegeboard.org.
default initialization of instance
variables, initialization blocks,
this(args)
63
Tested in the AP CS A Exam
Notes
Classes
13, 14
final,
visibility (private, protected),
new,
visibility (public),
accessor methods,
modifier (mutator) methods
Design/create/modify class.
Create subclass of a superclass
(abstract, non-abstract).
Create class that implements an interface.
Interfaces
Design/create/modify an interface.
Not tested in the AP CS A Exam,
but potentially relevant/useful
nested classes,
inner classes,
enumerations
13, 14
Inheritance
Understand inheritance hierarchies.
Design/create/modify subclasses.
Design/create/modify classes that
implement interfaces.
Packages
import packageName.* ,
static import,
package packageName ,
import packageName.className
class path
Miscellaneous OOP
“is-a” and “has-a” relationships,
15, 16
instanceof
(class) cast
this.var, this.method(args),
null,
this,
super.method(args)
Standard Java Librar y
17, 18
Object,
Integer, Double,
String,
Math,
List<E>, ArrayList<E>
64
clone,
autoboxing,
Collection<E>,
Arrays, Collections
© 2014 The College Board. Visit the College Board on the Web: www.collegeboard.org.
Notes
1. Students are expected to understand the operator precedence rules of the listed
operators.
2. The increment/decrement operators ++ and −− are part of the AP Java subset.
These operators are used only for their side effect, not for their value. That is,
the postfix form (for example, x++) is always used, and the operators are not
used inside other expressions. For example, arr[x++] is not used.
3. Students need to understand the “short circuit” evaluation of the && and ||
operators.
4. Students are expected to understand “truncation towards 0” behavior as well
as the fact that positive floating-point numbers can be rounded to the nearest
integer as
negative numbers as (int)(x − 0.5).
5. String concatenation + is part of the AP Java subset. Students are expected to know
that concatenation converts numbers to strings and invokes toString on objects.
6. User input is not included in the AP Java subset. There are many possible ways for
supplying user input: e.g., by reading from a Scanner, reading from a stream (such
as a file or a URL), or from a dialog box. There are advantages and disadvantages to
the various approaches. The exam does not prescribe any one approach. Instead, if
reading input is necessary, it will be indicated in a way similar to the following:
or
double x = ...;
// read user input
7. Both arrays of primitive types (e.g., int[], int[][]) and arrays of objects
(e.g., Student[], Student[][]) are in the subset.
8. Students need to understand that 2-dimensional arrays are stored as arrays of
arrays. For the purposes of the AP CS A Exam, students should assume that
2-dimensional arrays are rectangular (not ragged) and the elements are indexed
in row-major order. For example, given the declaration
int[][] m = {{1, 2, 3}, {4, 5, 6}};
m.length is 2 (the number of rows), m[0].length is 3 (the number of
columns), m[r][c] represents the element at row r and column c, and
m[r] represents row r (e.g., m[0] is of type int[] and references the
array {1, 2, 3}).
Students are expected to be able to access a row of a 2-dimensional array, assign
it to a 1-dimensional array reference, pass it as a parameter, and use loops
(including for-each) to traverse the rows. However, students are not expected to
analyze or implement code that replaces an entire row in a 2-dimensional array,
such as
© 2014 The College Board. Visit the College Board on the Web: www.collegeboard.org.
65
9.The main method and command-line arguments are not included in the subset.
In free-response questions, students are not expected to invoke programs. In the
AP Computer Science Labs, program invocation with main may occur, but the
main method will be kept very simple.
10. Students are required to understand when the use of static methods is
appropriate. In the exam, static methods are always invoked through a
class (explicitly or implicitly), never an object (i.e., ClassName.staticMethod( ) or
staticMethod( ), not obj.staticMethod( )).
11. If a subclass constructor does not explicitly invoke a superclass constructor, the
Java compiler automatically inserts a call to the no-argument constructor of the
superclass.
12. Students are expected to implement constructors that initialize all instance
variables. Class constants are initialized with an initializer:
public static final int MAX_SCORE = 5;
The rules for default initialization (with 0, false or null) are not included
in the subset. Initializing instance variables with an initializer is not included in
the subset. Initialization blocks are not included in the subset.
13. Students are expected to write interfaces or class declarations when given a
general description of the interface or class.
14. Students are expected to extend classes and implement interfaces. Students are
also expected to have knowledge of inheritance that includes understanding the
concepts of method overriding and polymorphism. Students are expected to
implement their own subclasses.
Students are expected to read the definition of an abstract class and understand
that the abstract methods need to be implemented in a subclass. Students are
similarly expected to read the definition of an interface and understand that the
abstract methods need to be implemented in an implementing class.
15. Students are expected to understand that conversion from a subclass reference
to a superclass reference is legal and does not require a cast. Class casts
(generally from Object to another class) are not included in the AP Java
subset. Array type compatibility and casts between array types are not included
in the subset.
16. The use of this is restricted to passing the implicit parameter in its entirety
to another method (e.g., obj.method(this)) and to descriptions such as “the
implicit parameter this". Students are not required to know the idiom
"this.var = var”, where var is both the name of an instance variable and a
parameter variable.
17. The use of generic collection classes and interfaces is in the AP Java subset, but
students need not implement generic classes or methods.
18. Students are expected to know a subset of the constants and methods of the
listed Standard Java Library classes and interfaces. Those constants and methods
are enumerated in the Java Quick Reference (Appendix B).
66
© 2014 The College Board. Visit the College Board on the Web: www.collegeboard.org.