Many people would think that sharks are mammals, but in fact they are not mammals, but a kind of fish, belonging to cartilaginous fish. Among fish, the size of the shark is a very large one, and even can be said to be the largest fish. Whales, on the other hand, are real mammals, although they are also named after "fish". Many people confuse sharks with whales and think that sharks are mammals, which is actually a misunderstanding.
As mentioned above, the shark is a cartilaginous fish, not a mammal. Many people tend to identify sharks as mammals, and most mammals are viviparous, so sharks are also viviparous. But that's not the case. Sharks are essentially oviparous animals, but they're different from what we know about ordinary oviparous animals. When defining the reproductive mode of sharks, some people will directly call it "oviparous" and others call it "ovoviviparous".
Due to various factors, the breeding methods of sharks have changed a lot after evolution. Their eggs will hatch inside them, and after the process of hatching is completed, they will be born, which seems to be similar to viviparity from this description. But it's not actually viviparous. If it's viviparous, there's an exchange of nutrients between the mother and the larva, but there's not a process of reproduction in sharks. Therefore, they can not be called viviparous animals.