Variables and Assignment Statements

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:

Do First

NEXT, put the 5 in the variable:

Do Second


Question 14:

What will this program fragment write?

    int quantity = 7; quantity = 13; System.out.println( "quantity holds: " + quantity );