PROBLEM DESCRIPTION
Given a number n and a bit number k, check if kth index bit of n is set or not. A bit is called set if it is 1. Position of set bit ‘1’ should be indexed starting with 0 from LSB side in binary representation of the number.
SOLUTION
1
2
3
4
5
class CheckBit {
static boolean checkKthBit(int n, int k) {
return ( (n&(1<<k)) != 0);
}
}