Infosys interview question

Stack heap array list oops