Hello All, In the enthuware mock tests which iam doing,iam encountering too many precedence related questions..But K and B explicitely mentions that only basic precedence stuff is more than necessary[like *,/ and % has more precedence than +,-]..can anyone comment on this..Any views from people who have cleared the exam is very much welcome..
Hi, I find this is more about "evaluate expressions from left to right" than precedence of operators. Would be different, if you remove all the brackets. And even then it was no more than + and * and += Bu.
all events occur in real time
Joined: Mar 22, 2004
Hello Bu, I dont think that knowledge alone can help you fix this problem. If you think so,than let me know how to apply it??
k += something or k = k + something something = ( (k = 4) * (k + 2) ) the k is taken stored into memory, and the result of "something" is added.
something = ( (k = 4) * (k + 2) ) from left to right again: here the first expression is (k=4) that means that the variable k now becomes 4 (was 1). further right: .......... * (k+2) k=4, from the step before, so (k+2) makes 6 (k=4) * 6
something = 4 * 6 = 24
and the whole thing: k += 24 k was one when we started the from left to right tour, so k= 1 + 24 the result is 25.
Another trick to visualize this is to mark where the k has what value. From left to right.
Now I'll quote it again:
I dont think that knowledge alone can help you fix this problem.
What else beside knowledge - can ? And what kind of knowledge you are thinking about? Knowledge about the K&B book, the language specification, arithmetics, boolean algebra? I really don't know what you are driving at.
Hello Bu, Thanks for the great explanation.. I was talking about K and B book as i mentioned in my first post itself..[Page 278 of book...given under exam watch].. Seems like i need to study bit more about operator precedence.
Up until the 5.0 exam Sun paid a lot of attention to operator precedence on the exam. As of the 5.0 exam the weighting of this topic (precedence) was greatly reduced and simplified. My advice is to spend your time on the tricky topics that get more weight. So, for instance, make sure that you've got a really solid understanding of threads, garbage collection, generics, collections, and classpaths, before you spend a lot of time on precedence. You're almost certainly going to get more questions on these topics than you will on precedence. If you've got everything else nailed, then certainly have fun studying precedence.
Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)