1/24
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
Object (Instance)
A specific entity created from a class blueprint using new; it has its own instance variables (state).
Instance Variable
A non-static field stored separately in each object; each instance has its own copy (e.g., each Student has its own name).
Instance Method
A non-static method that runs on a particular object and can directly access both instance variables and static variables of the class.
Static
A keyword meaning a member belongs to the class as a whole (shared), not to any one object.
Static Variable (Class Variable)
A field stored once per class (shared across all objects); changes affect what all instances “see.”
Static Method (Class Method)
A method that belongs to the class and is called with ClassName.methodName(...); it runs without needing an object.
Shared Counter Pattern
A common use of a static variable to track how many objects have been created (e.g., incrementing a static numStudents in the constructor).
Constructor
A special method that initializes a new object; it runs when you create an instance with new.
Class Loading (Static Memory Timing)
Static members are created once when the class is loaded, not each time an object is constructed.
Static Context Restriction
In a static method, you cannot directly access instance variables or instance methods because there is no specific object (this) available.
Object Reference Requirement (for instance access in static)
To use instance data inside a static method, you must use an object reference (e.g., take a Student s parameter and access s’s fields/methods).
Static Constant (static final)
A class-level constant shared by everyone; static makes it shared and final prevents reassignment after initialization.
Constant Naming Convention
In Java/AP CSA style, constants are typically written in ALL_CAPS (e.g., PI).
Dot Notation
Syntax like obj.method()/obj.field or ClassName.staticMethod() used to access members; it signals whether you’re using an object or the class.
Misleading Static Access via Object
Calling a static member through an object reference (e.g., s.getNumStudents()) still accesses the class member, not an object-specific one; prefer ClassName.member.
Scope
Where a name (variable/method) is visible and can be used in code, usually determined by blocks { }.
Local Scope
Scope of variables declared inside a method or inside a block (like if/for); they are usable only within that block.
Parameter Scope
Method/constructor parameters behave like local variables and are in scope throughout the method/constructor body.
For-Loop Variable Scope
A loop variable declared in a for header (e.g., int i) is only in scope inside the loop body (and loop header), not after the loop ends.
Shadowing
When an inner-scope variable (like a parameter) has the same name as an outer-scope variable (like an instance field), the inner one is used, hiding the outer one.
this Keyword
A reference to the current object (the instance whose constructor or instance method is running).
Disambiguation with this
Using this.field = parameter; to correctly assign to an instance variable when a parameter/local variable shadows the field.
Constructor Chaining (this(...))
Calling one constructor from another in the same class to reuse initialization logic (e.g., this(side, side)).
this(...) First-Statement Rule
A constructor call using this(...) must be the very first statement in the constructor, or the code will not compile.
Access Control
Rules that determine whether code from another class can use a field/method; commonly private (same class only) and public (accessible from other classes).