This behavior is called reflection.
Reflection is a change of in direction of the wave when it reaches another medium. Imagine a wave colliding with a glass in a tank of water.
During reflection, some of the initial energy of the wave is lost.
Waves always reflect with at same angle at which it approached the obstacle.