Amazon Interview Question

Bit manipulation related coding question to be implemented in OO style