When a wave reaches the boundary between two materials, called an interface, three things can happen. The wave can be reflected, which means it bounces back into the first material. It can be transmitted, which means it carries on into the second material, often changing speed and direction. It can be absorbed, which means its energy is transferred to the thermal store of the material, so the material becomes warmer. Usually a boundary does a mixture of all three.
Ultrasound is sound with a frequency above 20 000 Hz, too high for humans to hear. In a medical scan, short pulses of ultrasound are sent into the body. At each boundary between different tissues part of the pulse is reflected back as an echo and the rest is transmitted onwards. A detector picks up the echoes and a computer uses how long each one took to return to build up a picture.
Sonar works in the same way. A ship sends out a pulse of sound, often ultrasound, which is reflected by the seabed or a shoal of fish. Because the pulse travels there and back, the distance is found with distance = speed × time ÷ 2. For example, if the pulse takes 0.4 s and the speed of sound in water is 1500 m/s, the distance is 1500 × 0.4 ÷ 2 = 300 m. The total distance is divided by two because the depth is only half of the journey.