This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
x = (b1|b2&b3^4) ? x++ : --x; The expression can be solved in the following manner: Using the following operator preceence: 1> & AND 2> ^ XOR 3> | OR x = (true | ( true & true ) ^ true) ----- 1 x = (true | (true ^ true ) ) -------------2 x = (true | false) -----------------------3 x = true x evaluates to true so the answer is 0. Please correct if I am wrong! Regards, Milind
Joined: Feb 11, 2000
Hi Milind, The expression x = (b1|b2&b3^b4) ? x++ : --x; means if(b1|b2&b3^b4) x = x++; else x = --x; System.out.print(x) Now the boolean codn (b1|b2&b3^b4) returns true. So x = x++ should execute. My question is then x should be 1 instead of zero(because of x++)in the o/p. I just don't know why it is showing zero ! shatabdi