Velocity of light while coming out a denser medium

When light enters into a denser medium,its velocity decreases.I can understand it is due to the optical density.But when the light again comes out of the denser medium,how does it regain its speed(i.e velocity of light).

Light always propagates at c. The reason it seems to move through a medium slower is that it is adsorbed and re-emitted thus a delay is introduced. Sort of like driving down a street with stop signs. While you travel at the speed limit between signs your average velocity will be lower then the speed limit.

if absorbing & re-emitting is the phenomenon,why isn't it possible without the direction change?(i mean refraction)

I *believe* it is possible if the angle is perpendicular to the material. Like shining a laser pointer straight through a window. Since it isn't entering or leaving the material at an angle, there is no change in direction.

I *believe* it is possible if the angle is perpendicular to the material. Like shining a laser pointer straight through a window. Since it isn't entering or leaving the material at an angle, there is no change in direction.

Frequency dispersion in groups of gravity waves on the surface of deep water. The red dot moves with the phase velocity, and the green dots propagate with the group velocity. In this deep-water case, the phase velocity is twice the group velocity. The red dot overtakes two green dots, when moving from the left to the right of the figure.
New waves seem to emerge at the back of a wave group, grow in amplitude until they are at the center of the group, and vanish at the wave group front.
For surface gravity waves, the water particle velocities are much smaller than the phase velocity, in most cases.

This change of speed is not peculiar to light, it also happens to e.g. sound or water waves changing from one medium to another. You may compare it to the change in angular momentum when sitting on a spinning chair. When you stretch out your hands, your velocity will decrease, when you bring them back to your body, you accelerate again.
It's more or less the same with light. The momentum of the light in the denser medium does not change much also it's apparent velocity is lower as momentum is not only carried by the photons but also by the medium in which they propagate.

ZapperZ has commented on this in the Physics FAQ, and I am re-posting:

This question appears often because it has been shown that in a normal, dispersive solid such as glass, the speed of light is slower than it is in vacuum. This FAQ will strictly deal with that scenario only and will not address light transport in anomolous medium, atomic vapor, metals, etc., and will only consider light within the visible range.

The process of describing light transport via the quantum mechanical description isn't trivial. The use of photons to explain such process involves the understanding of not just the properties of photons, but also the quantum mechanical properties of the material itself (something one learns in Solid State Physics). So this explanation will attempt to only provide a very general and rough idea of the process.

A common explanation that has been provided is that a photon moving through the material still moves at the speed of c, but when it encounters the atom of the material, it is absorbed by the atom via an atomic transition. After a very slight delay, a photon is then re-emitted. This explanation is incorrect and inconsistent with empirical observations. If this is what actually occurs, then the absorption spectrum will be discrete because atoms have only discrete energy states. Yet, in glass for example, we see almost the whole visible spectrum being transmitted with no discrete disruption in the measured speed. In fact, the index of refraction (which reflects the speed of light through that medium) varies continuously, rather than abruptly, with the frequency of light.

Secondly, if that assertion is true, then the index of refraction would ONLY depend on the type of atom in the material, and nothing else, since the atom is responsible for the absorption of the photon. Again, if this is true, then we see a problem when we apply this to carbon, let's say. The index of refraction of graphite and diamond are different from each other. Yet, both are made up of carbon atoms. In fact, if we look at graphite alone, the index of refraction is different along different crystal directions. Obviously, materials with identical atoms can have different index of refraction. So it points to the evidence that it may have nothing to do with an "atomic transition".

When atoms and molecules form a solid, they start to lose most of their individual identity and form a "collective behavior" with other atoms. It is as the result of this collective behavior that one obtains a metal, insulator, semiconductor, etc. Almost all of the properties of solids that we are familiar with are the results of the collective properties of the solid as a whole, not the properties of the individual atoms. The same applies to how a photon moves through a solid.

A solid has a network of ions and electrons fixed in a "lattice". Think of this as a network of balls connected to each other by springs. Because of this, they have what is known as "collective vibrational modes", often called phonons. These are quanta of lattice vibrations, similar to photons being the quanta of EM radiation. It is these vibrational modes that can absorb a photon. So when a photon encounters a solid, and it can interact with an available phonon mode (i.e. something similar to a resonance condition), this photon can be absorbed by the solid and then converted to heat (it is the energy of these vibrations or phonons that we commonly refer to as heat). The solid is then opaque to this particular photon (i.e. at that frequency). Now, unlike the atomic orbitals, the phonon spectrum can be broad and continuous over a large frequency range. That is why all materials have a "bandwidth" of transmission or absorption. The width here depends on how wide the phonon spectrum is.

On the other hand, if a photon has an energy beyond the phonon spectrum, then while it can still cause a disturbance of the lattice ions, the solid cannot sustain this vibration, because the phonon mode isn't available. This is similar to trying to oscillate something at a different frequency than the resonance frequency. So the lattice does not absorb this photon and it is re-emitted but with a very slight delay. This, naively, is the origin of the apparent slowdown of the light speed in the material. The emitted photon may encounter other lattice ions as it makes its way through the material and this accumulate the delay.

Moral of the story: the properties of a solid that we are familiar with have more to do with the "collective" behavior of a large number of atoms interacting with each other. In most cases, these do not reflect the properties of the individual, isolated atoms.