Whales are classified as mammals and not as fish because they give birth to live young. They also have a sparse amount of fur on their bodies, they have lungs that breathe air and they give milk to their young.
Millions of years ago, some land mammals wandered from the land to the ocean and evolved to live there. Other such mammals include dolphins, walruses, seals and porpoises. In the case of both dolphins and whales, the front legs turned into flippers, while the back legs became small and hardly visible. The whale is the closest living relative of the hippopotamus.