I am studying Java and am having a problem with the following question.
Which of these statements are true?
The correct answers are b and c. However, I don't understand why those two are the answers. Can anybody explain it for me?
Take the expression a+1
for instance. This makes no sense as a statement as it does not change anything and is not possible.
x++
returns x
and increments it afterwards.
As it changes the variable, it can be used as a statement.
When you assign a value to something else, it returns the assigned value.
This is possible because x=0
sets x
to 0
and returns 0
.
Then, it sets y
to x
(0
) and returns this value (0
).
Then, it sets x
to y
(0) (and returns this value (0
)).