A pencil partly immersed in water in a glass tumbler appears to be displaced at the interface of air and water because
Light does not travel with same speed in all media.
Light travels fastest in the vacuum, but when it enters a denser medium the speed of light decreases. Hence, the light coming from the immersed part of the pencil bends away from the normal because the speed of light in air is more than in water. Due to this, the pencil appears displaced at the interface.