No, whales are unable to breathe underwater.
Unlike fish that are equipped with gills (which allow them to extract oxygen from the water) whales must come to the surface to breathe.
Whales breathe through their blowhole(s) and inhale/exhale oxygen when they are above the surface of the water.
When they dive the muscles surrounding their blowholes contract allowing the whale to swim underwater without having to fear anciently inhaling water.
When you see water spout from a whales blowhole that means that the whale is exhaling.
The water that spouts into the air comes from the water surrounding the blowhole, not water that was ingested by the whale.
If a whale were to inhale water into its blowhole the water would enter the whales lungs and the whale could drown.
The reason whales breathe through their blowhole and not their mouth is because the trachea (air passage) and esophagus (food passage) are not connected.
Because whales live in the ocean they must always be conscious of their breathing.
If a whale were to pass out while in the ocean there is a good chance it would sink and drown.
Because of this fact whales never fall completely asleep.
This is known as conscious breathing.
While they rest half of their brain remains active allowing them to respond to danger immediately.
Sometimes they can be seen logging across the surface of the ocean laying motionless so that they can easily inhale air without the fear of drowning.
It is believed that whales are also capable of sleeping while submerged but are likely to stay close to the surface so that they can come up for air when necessary.
Note: Whales, dolphins and porpoises are all marine mammals and belong to the cetacean species. All three species must come to the surface in order to breathe. None of them have gills or specialized lungs that would allow them to extract oxygen from water.