Amazon interview question

Bit manipulation related coding question to be implemented in OO style