In fact the Sun is very nearly an ideal gas , one in which particles do not interact appreciably with one another. The temperature of the Sun is so high that no molecules can form. The pressure at any point must be equal to the weight of the overlying gases. The temperature at any point is governed by the energy produced there, the energy entering and leaving the area, and the ability of the gases to conduct heat. Because stars are nearly ideal gases, it is much easier to arrive at a good knowledge of the interior of the Sun and stars using theoretical calculations than it is for the earth.
Ideal gases are much easier to deal with mathematically than solids or liquids are.
The Sun derives its energy by nuclear fusion, in a small central core . Nevertheless, the gas is still gas. Deep in the Sun, energy escapes outward by radiation , but near the surface of the Sun convection occurs, and the Sun's heat is transported by rising currents of hot gas. It takes several thousand years for energy to get from the core to the surface of the Sun.