Unit 3 Class Creation: Understanding Scope, Static Members, and Object References

0.0(0)
Studied by 0 people
0%Unit 3 Mastery
0%Exam Mastery
Build your Mastery score
multiple choiceMultiple Choice
call kaiCall Kai
Supplemental Materials
Card Sorting

1/24

Last updated 3:08 PM on 3/12/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

25 Terms

1
New cards

Object (Instance)

A specific entity created from a class blueprint using new; it has its own instance variables (state).

2
New cards

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).

3
New cards

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.

4
New cards

Static

A keyword meaning a member belongs to the class as a whole (shared), not to any one object.

5
New cards

Static Variable (Class Variable)

A field stored once per class (shared across all objects); changes affect what all instances “see.”

6
New cards

Static Method (Class Method)

A method that belongs to the class and is called with ClassName.methodName(...); it runs without needing an object.

7
New cards

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).

8
New cards

Constructor

A special method that initializes a new object; it runs when you create an instance with new.

9
New cards

Class Loading (Static Memory Timing)

Static members are created once when the class is loaded, not each time an object is constructed.

10
New cards

Static Context Restriction

In a static method, you cannot directly access instance variables or instance methods because there is no specific object (this) available.

11
New cards

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).

12
New cards

Static Constant (static final)

A class-level constant shared by everyone; static makes it shared and final prevents reassignment after initialization.

13
New cards

Constant Naming Convention

In Java/AP CSA style, constants are typically written in ALL_CAPS (e.g., PI).

14
New cards

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.

15
New cards

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.

16
New cards

Scope

Where a name (variable/method) is visible and can be used in code, usually determined by blocks { }.

17
New cards

Local Scope

Scope of variables declared inside a method or inside a block (like if/for); they are usable only within that block.

18
New cards

Parameter Scope

Method/constructor parameters behave like local variables and are in scope throughout the method/constructor body.

19
New cards

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.

20
New cards

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.

21
New cards

this Keyword

A reference to the current object (the instance whose constructor or instance method is running).

22
New cards

Disambiguation with this

Using this.field = parameter; to correctly assign to an instance variable when a parameter/local variable shadows the field.

23
New cards

Constructor Chaining (this(...))

Calling one constructor from another in the same class to reuse initialization logic (e.g., this(side, side)).

24
New cards

this(...) First-Statement Rule

A constructor call using this(...) must be the very first statement in the constructor, or the code will not compile.

25
New cards

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).

Explore top notes

note
Invisible Man Chapter 1
Updated 1173d ago
0.0(0)
note
Media & Information Literacy
Updated 322d ago
0.0(0)
note
Invisible Man Chapter 7
Updated 1173d ago
0.0(0)
note
Unit 3 : Macromolecules
Updated 313d ago
0.0(0)
note
International Cooperation
Updated 1195d ago
0.0(0)
note
Biochimie
Updated 746d ago
0.0(0)
note
Invisible Man Chapter 1
Updated 1173d ago
0.0(0)
note
Media & Information Literacy
Updated 322d ago
0.0(0)
note
Invisible Man Chapter 7
Updated 1173d ago
0.0(0)
note
Unit 3 : Macromolecules
Updated 313d ago
0.0(0)
note
International Cooperation
Updated 1195d ago
0.0(0)
note
Biochimie
Updated 746d ago
0.0(0)

Explore top flashcards

flashcards
S.S. Unit 3 - Study Guide
57
Updated 126d ago
0.0(0)
flashcards
Chapter 27
120
Updated 705d ago
0.0(0)
flashcards
Lit Words: 2 The Boogaloo
24
Updated 496d ago
0.0(0)
flashcards
Lab Practical 3
75
Updated 755d ago
0.0(0)
flashcards
Polyatomic Ions
21
Updated 768d ago
0.0(0)
flashcards
Latin Week 5
26
Updated 920d ago
0.0(0)
flashcards
Connect 4, Unit 3
52
Updated 1011d ago
0.0(0)
flashcards
S.S. Unit 3 - Study Guide
57
Updated 126d ago
0.0(0)
flashcards
Chapter 27
120
Updated 705d ago
0.0(0)
flashcards
Lit Words: 2 The Boogaloo
24
Updated 496d ago
0.0(0)
flashcards
Lab Practical 3
75
Updated 755d ago
0.0(0)
flashcards
Polyatomic Ions
21
Updated 768d ago
0.0(0)
flashcards
Latin Week 5
26
Updated 920d ago
0.0(0)
flashcards
Connect 4, Unit 3
52
Updated 1011d ago
0.0(0)