AP Computer Science A Flashcards: Assignment Statements and Input
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.
In an assignment statement, which side's value is stored and where is it stored?
The value of the expression on the right side of the assignment operator is calculated and then stored in the variable on the left side.
Card 1 of 10
All Flashcards (10)
In an assignment statement, which side's value is stored and where is it stored?
The value of the expression on the right side of the assignment operator is calculated and then stored in the variable on the left side.
What is the purpose of the assignment operator (=)?
The assignment operator (=) allows a program to initialize or change the value stored in a variable. It stores the value of the expression on the right in the variable on the left.
How would you write a basic line of code to read text input from the keyboard using the `Scanner` class?
You would first need to create a `Scanner` object, and then you could use one of its methods, such as `nextLine()`, to read input.
Besides text, what are some other forms of input a program can receive?
Input can come in a variety of forms, such as tactile, audio, and visual.
If `int count = 10;` is executed, followed by `count = count - 1;`, what is the final value stored in `count`?
The final value stored in `count` is 9. The expression `count - 1` is evaluated (10 - 1), and the result is stored back into the `count` variable.
What is the primary rule for using a variable in an expression?
Every variable must be assigned a value from a compatible data type before it can be used in an expression.
What is the `Scanner` class commonly used for?
The `Scanner` class is one way to obtain text input from the keyboard in a program.
After the statement `int total = 20 + 5;` is executed, what value is stored in the `total` variable?
The value stored in the `total` variable is 25. The expression on the right (20 + 5) is evaluated and its result is stored in the variable on the left.
What does it mean to initialize a variable?
A variable is initialized the first time it is assigned a value. Every variable must be initialized before it can be used in an expression.
What is the rule regarding data types when assigning a value to a variable?
The value being assigned to a variable must be from a compatible data type.