Buying stock in a bankrupt company is not much better than playing the lottery. 

When a company files for Chapter 11 bankruptcy protection, two things generally happen right away to its stock: a letter "q" is added to the end of the ticker symbol, and the price collapses.

Aeropostale (NASDAQOTH: AROPQ) recently filed for bankruptcy, and shares now trade for just $0.04 -- miles below their $15 price tag of just three years ago. While it may be tempting to pick up shares of a bankrupt company for a few cents each with the hope of profiting when the company emerges from bankruptcy, it's usually a bad idea. Here's why.

Who gets paid in a bankruptcy?

One of the main purposes of Chapter 11 bankruptcy is to pay off or restructure a company's debts in a way that allows it to continue operating in a sustainable manner. Which creditors get paid depends on the type and amount of the company's debt, as well as the value of the assets on its balance sheet. Once these are established, creditors get paid back according to the priority of their claims to the company's assets.

Secured creditors get paid first -- this typically means banks. If a company has, say, an outstanding bank loan or a mortgage secured by a building it owns, then these claims are dealt with first. Next up are unsecured creditors such as bondholders. If there are any preferred stockholders, they're next. Common stockholders are last to get paid, and unless the other creditors get paid in full or negotiate lower debt settlements, common stockholders usually end up with nothing.

Do shareholders ever get paid?

Note that I said common stockholders usually get nothing. There are some instances when companies emerge from bankruptcy and give common shareholders some form of compensation. Generally, this means a small portion of the company's newly created stock, or even a small cash payment.

However, this isn't a good reason to buy stock in bankrupt companies. It's quite rare for common shareholders to receive anything at all. In fact, of the 41 publicly traded companies that filed for bankruptcy protection in 2009 and 2010, common shareholders got a return in just four cases.

Even when common shareholders do get some form of compensation, it's likely to be minimal. Companies emerging from bankruptcy typically issue completely new stock, which can be issued to creditors in exchange for a more favorable debt settlement. Once new shares are issued, the old stock is canceled, and these shares become worthless. So, in the rare cases where shareholders are compensated, they may receive, for example, one share of the new stock for every 50 shares of the old stock.

The bottom line on bankrupt stocks

Sure, shareholders of bankrupt companies do get paid sometimes. Then again, so do some people who buy lottery tickets.

In the vast majority of cases, the odds are slim that common shareholders will receive anything at all when the smoke clears and the company emerges from bankruptcy, so it's best to avoid these stocks altogether. I'd even go so far as to say that if a stock you already own enters bankruptcy, your best bet is probably to unload your shares for pennies on the dollar. This way you'll at least walk away with something, and you'll have the realized capital loss to claim on your taxes.

This article represents the opinion of the writer, who may disagree with the “official” recommendation position of a Motley Fool premium advisory service. We’re motley! Questioning an investing thesis -- even one of our own -- helps us all think critically about investing and make decisions that help us become smarter, happier, and richer.