1/59
AP Computer Science A Exam Review Flashcards
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Identifier
Name for variable, parameter, constant, user-defined method/class, etc.
Built-in/Primitive Types
int, boolean, double
int
An integer, e.g. 5, -77, 9001
boolean
A boolean, true or false
double
A double precision floating-point number, 2.718, -3456.78, 1.4e5
Integer.MINVALUE and Integer.MAXVALUE
Represent the absolute lowest and highest values that can be stored in an integer
final variable
A quantity whose value will not change
Addition
Subtraction
Multiplication
/
Division
%
Mod (remainder)
Integer division note
Integer division truncates the answer (cuts off the decimal)
==
Equal to
!=
Not equal to
Greater than
<
Less than
=
Greater than or equal to
<=
Less than or equal to
!
NOT
&&
AND
||
OR
=
Simple assignment
+=
x = x + 4
-=
y = y - 6
*=
p = p * 5
/=
n = n / 10
%=
n = n % 10
++
k = k + 1
--
i = i - 1
Conditional Control Structures
if, if…else, if…else if
Looping Control Structures
while loop, for loop, for-each loop
Constructors
Create an object of the class
Accessor
Gets data but doesn’t change data
Mutator
Changes instance variable(s)
Static methods
Class methods, deals with class variables
Method Overloading
Two or more methods with the same name but different parameter lists
Inheritance
Where a subclass is created from an existing superclass
Class hierarchy
Superclass should contain the data and functionality that are common to all subclasses that inherit from the superclass
Implementing Subclasses
Subclasses copy everything except constructors
Inheriting Instance Methods/Variables
Subclasses cannot directly access private variables if they are inherited from a superclass
Method Overriding
If a method has the same name and parameter list in both the superclass and subclass, the subclass method overrides the superclass method
Super
Call up to the superclass
Polymorphism
Method overridden in at least one subclass is polymorphic
Abstract Class
Superclass that represents an abstract concept
Interface
Collection of related methods whose headers are provided without implementations
List
Basically the same as ArrayList
Lists and Arrays
Search, delete and insert an item.
1-D Arrays
First index starts at 0
Array Length
length is a public instance variable of arrays
Traversing an Array
Use for-each loop when you need to access (only access) every element in an array without replacing or removing elements
Selection Sort Algorithm
Search and swap
Insertion Sort Algorithm
Check element (store in temp variable). If larger than the previous element, leave it. If smaller than the previous element, shift previous larger elements down until you reach a smaller element (or beginning of array). Insert element.
Merge Sort Algorithm
Divide data into 2 equal parts, Recursively sort both halves, Merge the results
Binary Search
Check middle element. Is this what we’re looking for? If so, we’re done. Does what we’re looking for come before or after? Throw away half we don’t need. Repeat with half we do need
Binary search
Recursive
GridWorld Case Study
Bugs and Critters are 25% of the exam
Bug Methods
Bug moves if possible; otherwise turns.
BoxBug Variables
number of steps in a side of its square
Critter Class
Get a list of neighboring actors, Process actors, Get list of possible locations to move to, Select location from list, Move to location