My teacher told me that speed of light is constant in the universe. But in optics it is clearly shown that speed of light slows down in some objects. Please help.
The equations that describe how light, and all other electromagnetic radiation, works have a couple of constants which mean that the speed of light is constant. The equations don't depend on where you are, what temperature it is, which way you are looking etc so we assume they apply everywhere.
It is entirely possible (although experimentally unlikely) that these constants and so the speed of light were different in the early universe or now in some distant place.
The reason that the speed of light appears slower in glass or water is (simplified) that the light travels at the speed of light between the atoms but is absorbed by an atom, then re-emitted after a short delay, to continue tat the speed of light to the next one. This gives a "speed of light" which is slowed depending on the material.
My teacher told me that speed of light is constant in the universe.
Your teacher is mistaken I'm afraid. The speed of light varies with gravitational potential. You can see Einstein talking about this in 1920 in the Einstein digital papers:
Also see Irwin Shapiro saying the same in his Shapiro Delay paper dating from 1961:
There's also contemporary references such as Ned Wright's Deflection and Delay of Light: "In a very real sense, the delay experienced by light passing a massive object is responsible for the deflection of the light". Another one is Is The Speed of Light Everywhere the Same? by PhysicsFAQ editor and relativist Don Koks:
"Einstein talked about the speed of light changing in his new theory. In the English translation of his 1920 book "Relativity: the special and general theory" he wrote: "according to the general theory of relativity, the law of the constancy of the velocity [Einstein clearly means speed here, since velocity (a vector) is not in keeping with the rest of his sentence] of light in vacuo, which constitutes one of the two fundamental assumptions in the special theory of relativity [...] cannot claim any unlimited validity. A curvature of rays of light can only take place when the velocity [speed] of propagation of light varies with position." This difference in speeds is precisely that referred to above by ceiling and floor observers."
The underlying issue here is that that "the speed of light" is usually taken to mean "the locally-measured speed of light". This is constant by definition because we use the local motion of light to define our second and our metre, which we then use to measure the local speed of light. See http://arxiv.org/abs/0705.4507 where Magueijo and Moffat talked about it:
"As correctly pointed out by Ellis, within the current protocol for measuring time and space the answer is no. The unit of time is defined by an oscillating system or the frequency of an atomic transition, and the unit of space is defined in terms of the distance travelled by light in the unit of time. We therefore have a situation akin to saying that the speed of light is “one light-year per year”, i.e. its constancy has become a tautology or a definition."
What Einstein called the speed of light is nowadays often called the "coordinate" speed of light. If you ask whether this varies with gravitational potential, people will say yes. But many of them will then say that this isn't actually the speed of light, despite what Einstein and others said. As you can imagine, this does cause some problems.
But in optics it is clearly shown that speed of light slows down in some objects.
See what Martin Beckett said about light moving through glass. An analogy is perhaps useful here. Imagine you walk at 4mph. If the pavement is clear of people, you walk 4 miles in 1 hour. If however the pavement is crowded with people coming at you, you have to dodge around them. You still walk at 4mph, but after 1 hour you're only 3 miles down the street.