go to previous page   go to home page   go to next page hear noise highlighting

What happens FIRST when the following statement executes?

value = 2*3 ;

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 );

go to previous page   go to home page   go to next page