Use this AP CSA Unit 1.4 MCQ Practice set to review assignment statements, variable initialization, evaluating expressions before assignment, compatible data types, reference variables and null, and the role of input in a program. Work through 20 original, exam-style multiple-choice questions. Each question includes an explanation to help you understand the reasoning.
AP Exam Tip: For an assignment statement, evaluate the expression on the right side first, then store the resulting value in the variable on the left. A local variable must be initialized before it is used. Remember that null means a reference is not associated with an object.
AP CSA Unit 1.4 MCQ Practice: Key Concepts to Review
- Assignment operator:
=initializes a variable or changes the value it stores. The right-hand expression is evaluated and its value is stored in the left-hand variable. - Initialization: A variable is initialized the first time it is assigned a value. A local variable must be assigned before it is used in an expression.
- Type compatibility: The assigned value must be compatible with the variable’s declared type.
- Expressions: An expression evaluates to one value. Its type depends on the values and operations in the expression.
- Reference values: A reference variable can refer to an object or be assigned
null, which means it is not associated with an object. - Input: Programs can receive input in different forms. The
Scannerclass is one way to obtain text input from the keyboard.
Scope note: The College Board excludes assignment operators embedded inside expressions (such as chained assignment) and specific forms of user input from the AP CSA exam scope. This practice set therefore focuses on the required assignment concepts and the general role of input, not on memorizing particular Scanner input methods.
For the official course outline and exam information, consult the College Board AP Computer Science A course page.
AP CSA Unit 1.4 Exam Practice
Question 1 · Assignment operatorA program contains the statement int score = 18;. What happens when this statement executes?
The assignment operator (=) stores the value of the expression on its right in the variable on its left. Here, score is initialized with the value 18.
Question 2 · Direction of assignmentConsider the following code. What is the value of quantity after the assignment statement executes?
quantity = quantity + 3;
The right-hand expression is evaluated using the current value of quantity: 4 + 3 is 7. That result is then stored back in quantity.
Question 3 · InitializationWhich statement best describes when a local variable is initialized?
A variable is initialized the first time it is assigned a value. Declaring a local variable does not by itself give it a usable initial value.
Question 4 · Uninitialized variablesWhat is the result of attempting to compile and run this code?
System.out.println(points);
A local variable must be assigned a value before it is used. The compiler reports an error because points has not been initialized before it is read.
Question 5 · Assignment and expression evaluationWhat value is stored in result after the following code executes?
int result = base * 2 + 1;
The expression on the right is evaluated first. Multiplication is performed before addition, so 6 * 2 + 1 evaluates to 13, which is stored in result.
Question 6 · Changing a variable’s valueA variable has already been initialized. Which statement correctly changes the value stored in temperature to 25?
An assignment statement places the variable on the left and the value or expression on the right. The statement temperature = 25; updates the value stored in the variable.
Question 7 · Compatible data typesWhich assignment is valid in Java?
The value assigned must be compatible with the variable’s declared type. The decimal literal 4.8 is a double, so it can be assigned to a double variable. The other choices attempt incompatible assignments.
Question 8 · Assignment does not mean comparisonWhat is the purpose of the single equals sign (=) in a Java assignment statement?
In an assignment statement, = is the assignment operator. It stores the evaluated right-hand value in the variable named on the left. It does not test equality.
Question 9 · Sequential assignmentWhat are the values of x and y after this code executes?
int y = x;
x = 9;
When y = x; executes, the current value of x (5) is copied into y. Changing x later does not automatically change y. They are separate primitive variables.
Question 10 · Evaluating the right-hand expressionWhat value is stored in remaining?
int used = 7;
int remaining = total – used;
The expression total - used is evaluated as 20 - 7, producing 13. The result is then assigned to remaining.
Question 11 · Reference variables and nullWhat does the value null indicate when assigned to a reference variable?
The literal null is a special reference value indicating that a reference is not associated with an object. It is not the same as zero or an empty String.
Question 12 · Assigning nullWhich statement is valid Java if name is declared as a String variable?
A reference variable such as name can be assigned null, which means it is not currently associated with a String object. The other statements are not valid assignments.
Question 13 · Expression typeWhat is the type of the value produced by the expression 8 + 2 in Java?
Both operands are integer literals, so the arithmetic expression produces an int value. The type of an expression depends on the types of its operands and the operation being performed.
Question 14 · Expression type and assignmentWhich declaration and assignment correctly stores the result of 4.0 + 2?
The expression includes a double operand (4.0), so the arithmetic result is a double. A double variable is compatible with that result.
Question 15 · Assignment orderWhat is the value of count after the code executes?
count = count + 5;
count = count * 2;
Statements execute in order. First, count becomes 2 + 5 = 7. Next, the new value is multiplied by 2, so count becomes 14.
Question 16 · Assignment and object referencesA String variable named city currently refers to a String object. What happens when city = null; executes?
Assigning null changes the reference stored in city so that it is not associated with an object. It does not change the contents of the String object itself.
Question 17 · Reading inputA Java program needs to obtain text typed by a user at the keyboard. Which statement about the Scanner class is correct?
The College Board identifies the Scanner class as one way to obtain text input from the keyboard. Input can also come in other forms; the exam does not require a particular user-input method.
Question 18 · Input formsWhich choice is an example of input to a computer program?
Input is information supplied to a program for processing. A value typed by a user is text input. A message printed by the program is output, not input.
Question 19 · Assignment and output tracingWhat value is displayed by the final statement?
int second = first + 4;
first = second – 2;
System.out.println(first);
After the first two statements, first is 3 and second is 7. The third statement assigns 7 - 2, or 5, to first. Therefore, the program displays 5.
Question 20 · Assignment statements and algorithm implementationA program must store the sum of two previously initialized integer variables, apples and oranges, in fruitCount. Which statement correctly implements this step?
The target variable belongs on the left side of the assignment operator. The expression apples + oranges is evaluated, and its result is stored in fruitCount.
Practice Complete!
How to Prepare for AP CSA Unit 1.4 MCQ Practice
For this AP CSA Unit 1.4 MCQ Practice, trace each assignment statement in execution order. Evaluate the complete right-hand expression, check that its result is compatible with the variable’s type, and then update the variable. Watch for local variables that are used before initialization. For reference variables, distinguish null from an empty String or a numeric zero. For input questions, understand the general purpose of input and the role of Scanner without assuming that a particular input method is required by the exam.
AP CSA Unit 1.4 Exam-Readiness Checklist
- Explain how the assignment operator initializes or changes a variable’s stored value.
- Evaluate the right-hand expression before determining the value assigned.
- Recognize that a local variable must be initialized before it is used.
- Determine whether an assigned value is compatible with a variable’s declared type.
- Explain that an expression evaluates to one value and has a type.
- Explain what
nullmeans for a reference variable. - Describe the general role of input and identify
Scanneras one way to obtain keyboard text input.
Continue Your AP CSA Practice
Continue with Topic 1.5: Casting and Range of Variables, or return to the AP CSA Unit 1: Using Objects and Methods practice hub.
Curriculum alignment: This original practice set is aligned to the College Board AP Computer Science A Course and Exam Description (effective Fall 2025), Unit 1, Topic 1.4: Assignment Statements and Input (Learning Objectives 1.4.A and 1.4.B; Essential Knowledge 1.4.A.1–1.4.A.3 and 1.4.B.1). These are independently written practice questions, not released College Board exam questions. The College Board excludes assignment operators embedded inside expressions and specific forms of user input from the AP CSA exam scope.