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.
I hope you know that In Java, negative values are stored in two's complement format.
and int a = 3 does not mean a = 0011 in binary because int is 32 bit in java therfore a is 00000000 00000000 00000000 00000011 in binary now taking ~a ==> 11111111 11111111 11111111 11111100 which is a negative value . We will take two`s compliment now. Which comes out to be 4