The definition of ahoy is nautical or pirate lingo and is a term used to attract attention or say hello when boarding or aboard a boat.(interjection)
When you are going to board a ship and want to say hello to someone on the ship using traditional nautical lingo, this is an example of a time when you might say ahoy.
See ahoy in Webster's New World College Dictionary
Origin: a(h) + hoy
See ahoy in American Heritage Dictionary 4
Learn more about ahoy