IBM interview question

Oops concepts. Algorithms.