In a U-tube shell and tube heat exchanger, heat is transferred from the hot fluid to the cold fluid through the tube walls. The hot fluid stream circulates through the shell, surrounding the tube bundle, while the cold fluid stream circulates through the tubes. As the fluids flow through the heat exchanger, heat is transferred from the hot fluid to the cold fluid, allowing for efficient heat transfer and temperature control.