Variables and Assignment Statements
Read this chapter, which covers variables and arithmetic operations and order precedence in Java.
13. More Practice
Answer:
value holds: 6
More Practice
Here is another program fragment:
int extra;
extra = 5;
The assignment statement is correct. It matches the syntax:
variableName = expression;
The expression is the literal 5
. No calculation needs to be done. But the assignment statement still takes two steps.
FIRST, get the 5:
NEXT, put the 5 in the variable:
Question 14:
What will this program fragment write?
int quantity = 7;
quantity = 13;
System.out.println( "quantity holds: " + quantity );