It depends. If the company is bankrupt and has ceased operations, it becomes a shell corporation in essence. The buyer of a corporate shell can delist all of the existing shares of the company (those shareholders get nothing) and reissue them in another IPO if they so choose. The proceeds from sale of the publicly traded "shell" are used to satisfy outstanding creditors who filed claims during bankruptcy.
This was once a great strategy used by small investment banking firms to take a tiny business public via over-the-counter markets like Toronto or Philadelphia. They were better known as penny or "pinksheet" stocks because in the old days their listings were printed on pink paper. These companies couldn't meet the listing requirements to be on the larger exchanges.
Using a corporate shell like this makes it easier and faster to become traded because the company doesn't have to go through the same laborious, expensive, and time-consuming process of being approved through the SEC as a company normally would that intends to be traded on one of the bigger exchanges. I once worked for such a firm, helping to do this.