public int swap(int num,int i, int j){
        int t1 = (num & 1<<j) != 0 ? 1 : 0;
        int t2 = (num & 1<<i) !=0 ? 1 : 0;
        num = num & ~(1<<j);
        num = num & ~(1<<i);
        num = num | t1<<i;
        num = num | t2<<j;
        return num;
    }
http://www.careercup.com/question?id=17542662
src/com/interview/bits/SwapTwoBits.java