Page 1 of 1

About Question com.enthuware.ets.scjp.v6.2.336 :

Posted: Sun Oct 26, 2014 6:38 am
by milskruger
Hi,

I'm having trouble understanding why A is correct.
If we look at A, and we first do the mathematical equation before printing, then why is B wrong?

Thanks for the help.

M

Re: About Question com.enthuware.ets.scjp.v6.2.336 :

Posted: Sun Oct 26, 2014 7:23 am
by admin
Explanation to option 1 says + is left associative. It does not say that mathematical equation has to be done first.
Since + is left associative, option 2 is incorrect.
This explains what is meant by associativity: http://en.wikipedia.org/wiki/Operator_associativity
Once you read the above link, it will be clear.

HTH,
Paul.

Re: About Question com.enthuware.ets.scjp.v6.2.336 :

Posted: Sun Oct 26, 2014 9:22 am
by milskruger
Thanks Paul!