When I heat up coffee in the microwave and then pour in sugar, a layer of tiny dense bubbles forms at the top of the glass and stays there for the duration of the drinking, diminishing slightly over time. When I prepare the coffee by other means of heating this does not happen. What causes those tiny bubbles?
Upon addition of sugar to the superheated coffee, the formation of bubbles (phase transformation) occurs because the fine particles of sugar provide sites for the heterogeneous nucleation of gas from the liquid.
When the introduction of a fine inoculant (such as sugar particles) results in sudden fizzing of a liquid, it is an indication that there has been minor superheating of that substance.
Superheating tends to occur more in microwaves than on stovetops because people use metal saucepans/kettles on the stove, while generally using glass or glazed ceramic containers when heating a volume of water in a microwave oven.
When water is heated in a glass or glazed ceramic container rather than a metal one, the very hard surface of the container means that there are few scratches on it to act as sites for the heterogeneous nucleation of gas. Fewer heterogeneous nucleation sites means less heat loss through the transformation of liquid to gas.
This university site also makes a good point about the tendency for stovetop heating to cause localised superheating in the vicinity of the container walls... However, I think that this would tend to cause more boiling due to localised heating to the point that homogenous nucleation can occur (with the homogeneously nucleated bubbles then acting as further heterogenous nucleations sites) – not because of stirring of the water.
With regard to why your bubbles remained present for the duration of drinking, I would hypothesise that this perhaps has something to do with the oils in the crema of the coffee, and/or reaction of the dissolved sugar to form something that increases the surface tension of the water. (Not sure what you would call the opposite of a surfactant effect).
A final thing I would like to mention is that (as indicated on the UNSW page), microwaving liquids has the potential to result in violent reaction, or even explosion, of the liquid — in other words, you are risking serious burn injuries by taking a shortcut to heat it up.
Adding a powder (like sugar or instant coffee) to superheated water is particularly bad because in doing so, you are introducing millions of nucleation sites at once. That said, you should also be aware that since gas bubbles themselves promote heterogeneous nucleation, simply placing a spoon in the cup can be enough to cause an 'explosion'.
If you really need to microwave a liquid, (e.g., if you are cooking something), consider heating it in a microwave-safe plastic container that has been washed a few times (and is therefore abraded on the inside). You should also stop the microwave to check the temperature of the liquid at regular intervals, rather than nuking the fluid for an excessively long time.
This doesn't seem to be anything to do with the temperature, or at least not the temperature alone, because in my experience it only happens after the coffee has had a chance to sit (hot or cold) for more than about eight-ten hours. If you were to superheat (microwave) a very fresh cup in the same style container (coffee mug) then dump in a teaspoon of sugar, nothing happens - I've tested this because it has long bugged and perplexed me. I believe it must be some kind of oil into acid degradation (probably chlorogenic acid, mostly) to the point where a high enough concentration then reacts to the introduction of glucose leaving a transitional compound of excess lipids which encase particulates of both the sugar and coffee contaminants, which compound then would naturally collect a bit of the gas escaping the neutralization reaction as well, because of the viscosity difference between the lipids and the water. Put all that together - foamy residue. I'm not at all sure this is true, but it is my best hypothesis. My only other evidence supporting this is that if you allow the residue itself to adhere to your coffee cup, then rehydrate it slightly later, it feels like an oily/fatty substance when rubbed away.