Yes it's called a sonar. And would they even need to fire the sonar for that? Even using passive sonar they should be able to hear there's a boat above them considering how sensitive their sonars are. But operational mistakes can happen no matter how many sensors you have.
Also there's the periscope. And radio to warn nearby vessels.