Can hamsters have a heart attack if you throw them in the air?

Yes, if they don't die from other injuries (fractures, tissue damage to their unprotected abdomen) sustained during that kind of cruelty.