United Grade 11 AP Computer Science A (Java)
Chapters: 4
1. Using Objects and Methods
Introduction to Algorithms, Programming, and Compilers · Variables and Data Types · Expressions and Output · Assignment Statements and Input · Casting and Range of Variables · Compound Assignment Operators · Application Program Interface (API) and Libraries · Documentation with Comments · Method Signatures · Calling Class Methods · Math Class · Objects: Instances of Classes · Object Creation and Storage (Instantiation) · Calling Instance Methods · String Manipulation
- Programming Basics: Sequence, Selection, Loops and Functions – A program is a set of exact instructions a computer follows. Every program is built from three structures: sequence (steps in order), selection (if/else choices) and iteration (loops). Variables store values. Functions group code into reusable, named blocks, which makes programs modular and easier to test, debug and maintain.
- Python Basics: Modes, Variables, Data Types and Operators – Python runs in interactive mode (one line at a time) or script mode (a saved .py file). Blocks are shown by indentation. Variables are names tied to values; every value has a data type, and some types are mutable. Operators build expressions that Python works out by precedence. input() reads text, int()/float()/str() convert types, and debugging fixes syntax, runtime and logical errors.
- Object-Oriented Programming (OOP) – Object-oriented programming builds a program out of objects. A class is a blueprint that lists the data (attributes) and actions (methods) its objects will have. Each object is made from a class and keeps its own data. The four big ideas are encapsulation (hide data behind methods), inheritance (a new class reuses an old one), polymorphism (the same method call behaves in the right way for each object) and abstraction (show only what is needed).
- Strings in Python – A string is an immutable sequence of characters written in single, double or triple quotes. Each character has a positive index (0 from the left) and a negative index (−1 from the right). Operations: + (concatenation), * (repetition), in / not in (membership) and slicing s[start:stop:step], which takes characters from start up to but not including stop. Traversal means visiting each character with a for or while loop. Built-in methods like len(), upper(), lower(), title(), capitalize(), count(), find(), index(), replace(), split(), join(), strip(), startswith(), endswith(), isalpha(), isdigit(), isalnum(), islower(), isupper() and isspace() return new values without changing the original string.
2. Selection and Iteration
Algorithms with Selection and Repetition · Boolean Expressions · if Statements · Nested if Statements · Compound Boolean Expressions · Comparing Boolean Expressions · while Loops · for Loops · Implementing Selection and Iteration Algorithms · Implementing String Algorithms · Nested Iteration · Informal Run-Time Analysis
- Flow of Control in Python – Flow of control is the order in which statements run. Python has three kinds: sequential (top to bottom), selection (if, if-else, if-elif-else) and repetition (for and while loops). Blocks are marked by indentation (usually 4 spaces after a colon). range(start, stop, step) gives numbers from start up to but not including stop. while repeats as long as a condition is true. break exits a loop at once; continue skips to the next turn. A loop inside another is a nested loop and is used for patterns; loops with an accumulator are used for series sums.
- Control Statements in Python: if-else, while and for – Normally Python runs lines one after another (sequence). Control statements change this flow. if-else chooses one of two paths; if-elif-else picks the first true condition from many. while repeats a block while a condition is true; for repeats once for each item of a sequence such as range(start, stop, step).
- Strings in Python – A string is an immutable sequence of characters written in single, double or triple quotes. Each character has a positive index (0 from the left) and a negative index (−1 from the right). Operations: + (concatenation), * (repetition), in / not in (membership) and slicing s[start:stop:step], which takes characters from start up to but not including stop. Traversal means visiting each character with a for or while loop. Built-in methods like len(), upper(), lower(), title(), capitalize(), count(), find(), index(), replace(), split(), join(), strip(), startswith(), endswith(), isalpha(), isdigit(), isalnum(), islower(), isupper() and isspace() return new values without changing the original string.
- Algorithm Complexity: How Fast Does an Algorithm Grow? – Many algorithms can solve the same problem, but some need far more steps. We measure an algorithm by counting its basic steps as the input size n grows, not by stopwatch seconds. Big O notation names the growth: O(1) constant, O(log n) logarithmic, O(n) linear, O(n log n), and O(n²) quadratic. Linear search is O(n), binary search is O(log n); bubble sort is O(n²), merge sort is O(n log n). Memory used is space complexity.
3. Class Creation
Abstraction and Program Design · Impact of Program Design · Anatomy of a Class · Constructors · Methods: How to Write Them · Methods: Passing and Returning References of an Object · Class Variables and Methods · Scope and Access · this Keyword
- Object-Oriented Programming (OOP) – Object-oriented programming builds a program out of objects. A class is a blueprint that lists the data (attributes) and actions (methods) its objects will have. Each object is made from a class and keeps its own data. The four big ideas are encapsulation (hide data behind methods), inheritance (a new class reuses an old one), polymorphism (the same method call behaves in the right way for each object) and abstraction (show only what is needed).
4. Data Collections
Ethical and Social Issues Around Data Collection · Introduction to Using Data Sets · Array Creation and Access · Array Traversals · Implementing Array Algorithms · Using Text Files · Wrapper Classes · ArrayList Methods · ArrayList Traversals · Implementing · 2D Array Creation and Access · 2D Array Traversals · Implementing 2D Array Algorithms · Searching Algorithms · Sorting Algorithms · Recursion · Recursive Searching and Sorting
- Data Analysis – Data analysis means turning raw data into answers. It follows a cycle: ask a question, collect data, clean it (remove errors, repeats and blanks), organise and transform it, analyse it with summaries such as mean, median, range and patterns, show it with a good chart, and draw a careful conclusion. Watch for outliers, small samples and bias, and remember that a correlation between two things does not prove that one causes the other. Data must also be stored safely and used with permission.
- Arrays and Lists: Storing Many Values in One Name – An array is a row of numbered boxes that share one name. Each box holds one value and has an index that starts at 0. We read or change a box with its index, visit every box with a loop (traversal), and use that loop for standard algorithms: sum, average, largest, count and linear search. A 2D array is a grid of rows and columns, read with two indexes and two nested loops. A fixed array has a set length; a list (Python list, Java ArrayList) can grow and shrink.
- File Handling in Python: Save Data That Lasts – Variables vanish when a program ends; files keep data on the disk. A text file stores characters in lines, a binary file stores raw bytes (such as pickled Python objects), and a CSV file stores table rows with commas. You open a file with open(path, mode), using an absolute or relative path and a mode such as r, w, a, r+, rb or wb. The with statement closes the file for you. Text files use write, writelines, read, readline and readlines. seek moves the file pointer and tell reports where it is. pickle.dump and pickle.load save and load objects in binary files, letting you search, append and update records. The csv module's writer (writerow, writerows) and reader handle CSV files.
- Lists in Python: Create, Traverse, Change and List Methods – A list is an ordered, changeable collection written in square brackets, like [10, 20, 30]. Items are reached by index (from 0, or negative from the end) and slices. We traverse a list with a for loop, change items in place because lists are mutable, and use functions (len, max, min, sum, sorted, list) and methods (append, insert, extend, remove, pop, sort, reverse, count, index, clear) to work with it.
- Programming Basics: Sequence, Selection, Loops and Functions – A program is a set of exact instructions a computer follows. Every program is built from three structures: sequence (steps in order), selection (if/else choices) and iteration (loops). Variables store values. Functions group code into reusable, named blocks, which makes programs modular and easier to test, debug and maintain.
- Searching and Sorting Algorithms – A searching algorithm finds an item in a list; a sorting algorithm puts a list in order. Linear search checks items one by one and works on any list. Binary search halves a sorted list each time and is much faster. Bubble sort swaps neighbours pass by pass; merge sort splits the list and merges sorted halves, which is faster for big lists.
- Sorting Algorithms – A sorting algorithm puts a list in order. Bubble sort swaps neighbours, insertion sort slides each item into a sorted part, selection sort picks the smallest each time, and merge sort splits the list and merges sorted halves. Merge sort needs far fewer comparisons on long lists (about n log₂ n instead of about n²/2).
- Recursion: Functions That Call Themselves – Recursion is when a function solves a problem by calling itself on a smaller version of the same problem. Every recursive function needs a base case, where it stops and returns an answer directly, and a recursive case that moves closer to the base case. Each call gets its own stack frame on the call stack; frames are removed as calls return.