Atmospheric refraction : Refraction of light caused by the earth's atmosphere due to change in the refractive indices of different layers.
(i) Twinkling of stars : Stars are distant point sized source of light. The path of the rays of light coming from star goes on varying due to atmospheric refraction slightly. Thus apparent position of the stars fluctuates and the amount of star light entering the eye flickers giving the twinkling effect.

(ii) Advanced sun-rise : When the sun is slightly below the horizon, light rays coming from the sun travel from the rarer to denser layers of air. Because of atmospheric refraction of light, light appears to come from a higher position above the horizon. Thus sun appears earlier than actual sunrise.
Delayed sunset : Same reason as similar refraction occurs at the sunset.
