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

Moderator: admin

Post Reply
milskruger
Posts: 4
Joined: Sun Oct 26, 2014 6:33 am
Contact:

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

Post by milskruger » Sun Oct 26, 2014 6:38 am

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

admin
Site Admin
Posts: 8619
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post by admin » Sun Oct 26, 2014 7:23 am

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.
If you like our products and services, please help us by posting your review here.

milskruger
Posts: 4
Joined: Sun Oct 26, 2014 6:33 am
Contact:

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

Post by milskruger » Sun Oct 26, 2014 9:22 am

Thanks Paul!

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest