Let's write a method that accepts a bit position and an integer and returns true if its zero. That's the only thing that distinguishes your task from a task that has inputs and outputs.
static public boolean isZero(int position, int value)
{
position -= 1; // zero based position
int mask = 1; // single bit mask
// Move the mask bit in to position
mask <<= position;
// Mask off all bits except for the target
value &= mask;
// If the whole value is zero then the masked bit was zero
return value == 0;
}
Now, to
test this use hexadecimal numbers. You can easily tell which bits are zero with a hex number so that's a good format for testing:
public static void main(
String[] args)
{
System.out.print(isZero(4, 0xF8));
}