When light travels from a rarer medium to a denser medium, its speed decreases. Since the frequency of light remains constant when it enters a new medium, its wavelength decreases.
The relationship between the speed \( v \), frequency \( f \), and wavelength \( \lambda \) is given by: \[ v = f \lambda \]
Since the frequency remains constant and the speed decreases in a denser medium, the wavelength must decrease.
Hence, the correct answer is (D).