Whales and other marine animals are mammals. It is believed for more than 60 million years ago marine mammals were land mammals and had to adapt to the sea for lack of food on earth, or some other source of vital importance.
Cetaceans can be divided into:
Odontocetes (with teeth) than are dolphins, orcas, narwhals, belugas, sperm whales.
Baleen whales like humpback whales, and southern right whale, among others.
In the pictures you can see the mouth and the beard of the southern right whale, all of which used to filter krill and plankton that serves as food, once it fills the mouth of these organisms along with the salt water that contains, the tongue pushes the aqueous volume and beards retain krill or plankton, letting the water.