Variables and Assignment Statements

12. Two Steps


Answer:

FIRST, do the multiplication 2*3 to get the value 6.

Two Steps

FIRST, do the multiplication 2*3 to get the value 6.

Do First

NEXT, put the result of the calculation into the "litte box of memory" used for the variable value:

Do Second

It will really, really help you to think carefully about these two steps. Sometimes even second year computer science majors get confused about this and write buggy code.


Question 13:

What will this program fragment write?

    value = 2*3; System.out.println( "value holds: " + value );