Infosys interview question

Class extension