public int reverse(int num){
        //assuming int is 32 bits.
        int result = 0;
        int r1 = 1;
        for(int i=31; i >= 0; i--,r1<<=1){
            if((num & 1<<i) != 0){
                result = result | r1;
            }
        }
        return result;
    }
http://www.geeksforgeeks.org/write-an-efficient-c-program-to-reverse-bits-of-a-number/
src/com/interview/bits/ReverseBits.java