Title: Java: AP Curriculum Focus and Java Subset
1Java AP Curriculum Focus and Java Subset
2Curriculum Topics
- Object-oriented programming and design
- Declaring and constructing objects
- Invoking methods
- Interacting objects
- Class implementations, including method
implementations - Parameter passing
- Basic control flow constructs
3Curriculum Topics (continued)
- Data Structures
- Primitive types
- Classes
- Arrays and ArrayLists
- Maps and Sets (AB)
- Stacks and Queues (AB)
- Linked Lists (AB)
- Trees (AB)
- Heaps, Priority Queues (AB)
4Curriculum Topics (continued)
- Algorithms
- Traversing Linear Data Structures
- Accumulate
- Find Min/Max
- Searching (e.g., linear, binary)
- Sorting
- Traversing Linked Lists and Trees (AB)
- Analyzing space and time performance (formal
analysis -- AB)
5AP Java Subset
- Why have a subset?
- Language is big cant cover everything.
- Libraries are bigger cant cover everything.
- Exam cant test everything.
- Exam should test fundamental ideas, not every
esoteric (or interesting, or even useful)
language construct. - Subset defines/limits what may be on the exam,
not what you can cover.
6Java Subset
- Primitive Types (similar to C)
- int, double, boolean
- arithmetic operators - / --
- relational logical ! lt lt !
- assignment etc.
- numeric casting (int) (double), truncation
- char is not required by subset
7Java Subset (continued)
- String class (similar to apstring)
- Declaring and constructing strings
- String constants
- String concatenation ()
- converting numerics to strings
- converting objects to strings (toString)
- Escape sequences \\ \ \n
8Java Subset (continued)
- I/O
- System.out.print, System.out.println
- No other I/O will be tested, so you can use
whatever techniques you and your textbook choose,
e.g., keyboard input, text fields in graphical
user interfaces, mouse events, applets, etc. - Case study also uses Debug.print, Debug.println
9Java Subset (continued)
- Control Structures (similar to C)
- if, if - else, if - else if - else
- for, while
- return
- Comments (similar to C)
- //
- / /
- Case study uses doc. comments / /
10Java Subset (continued)
- Using Objects
- Constructing objects using new, passing
parameters to constructors as necessary - Variables are references to objects
- Dot notation for invoking methods
- Use of this to pass self to other objects
- Difference between and equals
- null reference
11Java Subset (continued)
- Defining Classes
- public/private static final constants
- private instance variables (data members)
- public and private constructors and methods
(member functions)
12Java Subset (continued)
- Methods
- Method calls and method definitions
- Constructors, accessors, modifiers
- Parameter passing (always pass-by-value, but
passing references by value feels like
pass-by-reference) - Method overloading signature depends on number,
type, order of parameters - super.method to call overridden method definition
13Java Subset (continued)
- Constructors (similar to C)
- Name is same as class no return value
- Initialize instance variables in constructors (no
initialization lists) - Call super to initialize inherited data
- static constants are initialized when declared
- public static final CONSTANT init_expr
14Java Subset (continued)
- Standard Java Library Classes (A list)
- java.lang.Object
- java.lang.Comparable (AB only?)
- java.lang.Integer, java.lang.Double
- java.lang.String
- java.util.ArrayList
- java.lang.Math
- java.util.Random
- import statement
15Java Subset (continued)
- Linear Indexed Data Structures
- 1D (A) and 2D (AB) arrays, similar to apvector
- bounds checking
- myArrayi.length
- 2D arrays are AB material
- ArrayList class
- Core subset of methods
- Casting from Object to specific class (and
casting more generally in other contexts)
16Java Subset (continued)
- Inheritance and Interfaces
- Implementing interfaces
- Extending classes
- inheriting data and methods
- overriding methods
- dynamic binding (polymorphism)
- Abstract classes
17Java Subset (continued)
- Exceptions (unchecked exceptions)
- Understand when they occur
- NullPointerException, ArrayIndexOutOfBoundsExcepti
on, ArithmeticException, ClassCaseException,
IllegalStateException, NoSuchElementException
18Java Subset (continued)
- What is NOT in the subset (not testable)?
- char
- most I/O
- main method (used in case study) and applets
- do/while, switch, break
- protected visibility (used in case study)
- many other features
19Java Subset (AB Additions)
- Standard Java Library Classes
- java.lang.Comparable (officially AB only)
- java.util.List (interface)
- java.util.ArrayList implements java.util.List
- java.util.LinkedList implements java.util.List
- java.util.Set (interface)
- java.util.HashSet implements java.util.Set
- java.util.TreeSet implements java.util.Set
- java.util.Iterator
- java.util.ListIterator extends java.util.Iterator
20Standard Java Lists (java.util)
List (interface) boolean add(Object x) int
size() Iterator iterator() ListIterator
listIterator()
ArrayList Object get(int index) Object set(int
index, Object x) void add(int index, Object
x) Object remove(int index)
LinkedList void addFirst(Object x) void
addLast(Object x) Object getFirst() Object
getLast() Object removeFirst() Object removeLast()
21Standard Java Sets (java.util)
Set (interface) boolean add(Object x) boolean
contains(Object x) boolean remove(Object x) int
size() Iterator iterator()
HashSet
TreeSet
22Standard Java Lists (java.util)
Iterator (interface) boolean hasNext() Object
next() void remove()
ListIterator (interface) void add(Object x) void
set(Object x)
23Collections (NOT in Subset!)
Collection (interface) boolean add(Object
x) boolean contains(Object x) boolean
remove(Object x) int size() Iterator iterator()
List ListIterator listIterator()
Set
24Java Subset (AB Additions)
- Standard Java Library Classes
- java.util.Map (interface)
- java.util.HashMap
- Java.util.TreeMap
- java.lang.Object
- int hashCode()
25Standard Java Maps (java.util)
Map (interface) Object put(Object key, Object
value)) Object get(Object key) boolean
containsKey(Object key) int size() Set keySet()
HashMap
TreeMap
26Java Subset (AB Additions)
- AP CS ListNode and TreeNode Classes
- Interfaces for Stack, Queue, PriorityQueue
- There is a java.util.Stack class, but this is not
the same as the AP interface and is not in the
subset