can u explain this scenario briefly????

plz give correct code.