PrepGo

AP Computer Science A Flashcards: Class Variables and Methods

Written by AP Content Team, Verified for 2026 AP Exams, Last updated: May 2026

Review key ideas with interactive flashcards. This set includes 10 cards to help you master important concepts.

How can a class method call an instance method?
A class method can only call an instance method if it is passed an instance of the class via a parameter.
Card 1 of 10

All Flashcards (10)

How can a class method call an instance method?
A class method can only call an instance method if it is passed an instance of the class via a parameter.
What is the primary purpose of class methods?
The primary purpose of class methods is to define the behaviors of a class.
A `static` method needs to modify a non-static `name` field. What must be provided to the method?
The method must be passed an instance (an object) of the class via a parameter to access or change the instance variable `name`.
To what do class variables belong?
Class variables belong to the class itself, not to individual objects.
If multiple objects are created from a class, how many copies of a class variable exist?
Only a single copy of the class variable exists, which is shared among all objects of that class.
Can a class method access instance variables directly?
No, class methods cannot access or change the values of instance variables directly.
How do you declare a class variable in your code?
You declare a class variable by using the `static` keyword before the variable's type.
What is a major restriction for class methods when interacting with instance variables?
Class methods cannot access or change the values of instance variables without being passed an instance of the class.
What is a class variable?
A class variable belongs to the class itself, and all objects of that class share a single copy of it.
What keyword is used to designate a class variable?
Class variables are designated with the `static` keyword before the variable type.