Cool stars, like the Sun, have convective envelopes
which support a magnetic dynamo, which heats a
corona to X-ray emitting temperatures via magnetic
reconnection (and other magnetic processes, perhaps)