260 likes | 607 Views
Java: AP Curriculum Focus and Java Subset. Alyce Brady. Curriculum Topics. Object-oriented programming and design Declaring and constructing objects Invoking methods Interacting objects Class implementations, including method implementations Parameter passing
E N D
Java: AP Curriculum Focus and Java Subset Alyce Brady
Curriculum 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
Curriculum 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)
Curriculum 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)
AP Java Subset • Why have a subset? • Language is big; can’t cover everything. • Libraries are bigger; can’t cover everything. • Exam can’t 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.
Java Subset • Primitive Types (similar to C++) • int, double, boolean • arithmetic operators: + - * / % ++ -- • relational & logical: == != < <= && || ! • assignment: = += etc. • numeric casting: (int) (double), truncation • char is not required by subset
Java 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
Java 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
Java 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 /** … */
Java 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
Java Subset (continued) • Defining Classes • public/private static final constants • private instance variables (data members) • public and private constructors and methods (member functions)
Java 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
Java 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: publicstaticfinalCONSTANT = init_expr;
Java 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
Java Subset (continued) • Linear Indexed Data Structures • 1D (A) and 2D (AB) arrays, similar to apvector • bounds checking • myArray[i].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)
Java Subset (continued) • Inheritance and Interfaces • Implementing interfaces • Extending classes • inheriting data and methods • overriding methods • dynamic binding (polymorphism) • Abstract classes
Java Subset (continued) • Exceptions (unchecked exceptions) • Understand when they occur • NullPointerException, ArrayIndexOutOfBoundsException, ArithmeticException, ClassCaseException, IllegalStateException, NoSuchElementException
Java 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
Java 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
Standard 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()
Standard Java Sets (java.util) Set (interface) boolean add(Object x) boolean contains(Object x) boolean remove(Object x) int size() Iterator iterator() HashSet TreeSet
Standard Java Lists (java.util) Iterator (interface) boolean hasNext() Object next() void remove() ListIterator (interface) void add(Object x) void set(Object x)
Collections (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
Java Subset (AB Additions) • Standard Java Library Classes • java.util.Map (interface) • java.util.HashMap • Java.util.TreeMap • java.lang.Object • int hashCode()
Standard 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
Java 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