If an astronaut threw a cup of coffee into space somehow, would it freeze into a block, or boil off into gas due to the zero pressure?
This was tested nearly sixty years ago. Using a very large cup filled with 95 tons of water. An empty second stage of a Saturn I under test was used. Only the first stage should be tested but with full payload of a water-filled dummy upper stage. Dummies with the tanks but without the expensive engines. The dummies should have the same shape and mass as a real second stage and the center of mass should be at the same position. The test of the first stage required dummies with water ballast anyway, only an explosive charge was needed to release the water at the highest point.
Title: Saturn I SA-2 Launch
Description: The second flight of the Saturn I vehicle, the SA-2, was successfully launched from Cape Canaveral, Florida on April 15, 1962. This vehicle had a secondary mission. After the first stage shutoff, at a 65-mile altitude, the water-filled upper stage was exploded, dumping 95 tons of water in the upper atmosphere. The resulting massive ice cloud rose to a height of 90 miles. The experiment, called Project Highwater, was intended to investigate the effects on the ionosphere of the sudden release of such a great volume of water.
Credit: NASA Marshall Space Flight Center (NASA-MSFC)
So the water would not freeze to a block but to a cloud of ice crystals. These small ice particles would not melt but turn into water vapor directly. This is called sublimation: when a solid goes directly to vapor without a liquid state between solid and gaseous.
But how does the water turn into ice? The liquid water releases some vapor and cools down by the vaporisation. So a part of the liquid goes to vapor and the rest to ice. Vaporisation of water removes a lot of heat energy.
A report of 127 pages was written.
But what about the cup of coffee? In zero gravity you can't handle liquids in cups. In the pressurized capsule, the coffee will float free, its shape will be a sphere. If you depressurize the capsule to expose the coffee to the vacuum of space, the water will boil at lower air pressure, a part will turn into vapor and the rest into ice crystals. The ice crystals will be vented together with the air into space. When pressure is so low that the hatch may be opened only very few crystals are left in the capsule.
If you want to see what happens to a small water volume in space, you need a closed and pressurized bottle to take the water out of the capsule. If you open the bottle, you will see the cloud of ice crystals.
It would not freeze into a block. It would quickly expand and boil, but not in a rolling boil. Without pressure, bubbles would form throughout the coffee and expand rapidly, causing it to spray out of the mug as soon as you released the catch that would have been necessary to hold the lid on. But evaporation causes cooling, so millions of frozen coffee crystals would form and quickly disperse. At our distance from the sun the crystals would then evaporate (that is, sublime) over time. In deep space, far from the sun, they might last indefinitely.
While the existing answers appear mostly right to me, especially on the "part will turn into vapor and the rest into ice crystals" fact, I think they omit one interesting explanation. Namely, why does evaporation cause cooling - understanding which seems to suggest the exact effect will depend on how violently you throw the cup.
While I've never conducted such an experiment in 0g, I have done it repeatedly in 1g, to explain this particular phenomenon. So, I'll start with the part I have seen (using water and a vacuum pump).
What is evaporation? Is it random which part of a liquid evaporates and which remains? Not quite. On the microscopic level it is, somewhat self-explanatory, the molecules which break past the surface that form the vapour. Now, in the liquid, as elsewhere, the molecules have a distribution of different kinetic energy values. The ones most likely to escape are those with the highest kinetic energy. When these are gone, the ones which stayed have, on average, lower kinetic energy. This energy is precisely the temperature - getting lower.
So, you'll have the higher-energy molecules turn to vapour, and the low ones - into ice. In 1g, those stay together at the bottom of the vessel. For a bit of 0-g speculation: depending on how big the cup is, and how violently it is thrown, I'd think these low-energy remnants can form larger or smaller ice crystals. Most will be vapour either way.
Assuming total darkness and a coffee temperature below the boiling point in space The coffee can only cool down by emitting radiation. If the coffee is thrown out hot or cold has the only difference that it takes a bit longer for the hot coffee to freeze than the cold coffee. If the space is dark and the coffee is given a lot of velocities it will get torn into small droplets and it will cool down and freeze. If the droplets are very small, almost immediately all heat will be radiated away. So if you can throw like spraying it will be a nice sight.
The radiation loss of the coffee will be the highest for large sheets of connected coffee. A flat sheet of coffee will radiate its heat away the fastest. So if you manage to throw a sheet of coffee out of the cup, you will see the sheet turning solid. The thinner the sheet the faster it freezes.
The frozen coffee will end up in thermodynamic equilibrium with the vacuum of space, reaching a shivering temperature of about 2.7(K).
The temperature of the water is below the boiling temperature on Earth. But in space this boiling temperature is lower. So if it has the boiling temperature of space it will be boiled to small droplets, causing a spray. No matter how you throw it. For lower temperatures, the above scenario suffices.