I have a reference book now, but it shows the bitwise operators all in the same precedence, so from that I would guess that left to right would apply.... I loaded the expression into a test program. Compile and run... The answer is 11 - you were right. The real question is: Do we need to know this level of precedence for the SCJP2 exam?
I don't know which "reference" book you have, but I use Java in a Nutshell (2ed) from O'Reilly which correctly lists the precedence of all the operators on pages 228 and 229. And no, I don't think you really need to know it in that much detail. Especially as you can afford to lose a few points and still pass.
I'm wanting to get a high score. I'm certain I could have passed the test weeks ago. But it's those last few percentage points I want to reduce. So - this sort of stuff WILL be on the test. Right? I have the Java in a nutshell book - thanks for the info. I'll have to try to memorize this stuff I guess.
i post this from jls 15.21 for operator precedence for & , ^ and |. These operators have different precedence, with & having the highest precedence and | the lowest precedence. Each of these operators is syntactically left-associative (each groups left-to-right). [This message has been edited by rahul_mkar (edited May 04, 2000).]
My friend, you really need any point that comes your way, and you can not afford to lose apoint when you dont know what the next question brings. You DO have to know the operator precedence because it accounts to answering so many questions. Moreover, you need to know it to be a real programmer.
I made up a mneomonic (im sure i spelled that wrong!) for the operator precedence "you ask bullshit then assign" U - Unary A - Arithmetic S - Shift C - (mneumonic licence) Comparison B - Bitwise S - Shortcut T - Ternary A - Assign Works out to U ASC BullShit Then Assign
posted 19 years ago
hi Nalini Mistry could u please provide us with an example to clarify and end this thread