Virtusa interview question

Some basic programming question and it's explanation