Consider a slinky – a metal wire precomposed into a helical spring. ('Slinky' meaning "sleek and graceful" is an interesting toy). Let the slinky′s one end be tied to a wall. Just compress the slinky once and watch the pulse go along the slinky. The pressure (or density) wave looks like a transverse wave!
What happens when the pulse reaches the wall? The reflection of the pulse depends on the wall. If the wall is very rigid, the pulse will be reflected. On the other hand, if the wall is soft, or the end is free, the reflection of the pulse will not be that strong – some energy from the pulse will be transmitted to the wall or lost to air. These principles of reflection of a slinky pulse can be applied to sound waves.
Like light, the sound gets reflected at the surface of a solid or liquid and follows the same laws of reflection.