What determines the temperature of a white dwarf?

Can someone please explain what determines the temperature of the white dwarf? Is more massive white dwarf hotter ? Also, is the density of a white dwarf always a constant?

White dwarfs are "dead cinders" which are hot because they formed hot. Once it has formed, a white dwarf spends most of its time cooling down.

The surface temperature of a white dwarf is about 100 times hotter than its interior - which is nearly isothermal. After the white dwarf has formed the surface temperature falls from $$>100,000$$ K in the first million years or so after formation, to 10,000 K after about a billion years and pehaps 4000 K after 10 billion years.

The main thing that determines the temperature of a white dwarf is therefore how long ago since it formed and started cooling.

The mass of a white dwarf is a somewhat secondary parameter that influences the cooling rate. A more massive white dwarf has more internal heat energy for the same temperature. However, it turns out that more massive white dwarfs also radiate more luminosity, so these two effects almost cancel. A more subtle effect of mass is that more massive white dwarfs are smaller and much denser. This leads to them crystallising more readily - this raises the specific heat capacity and releases latent heat, which delays their cooling. On the other hand, at later times, the massive white dwarfs will enter the quantum Debye cooling stage, resulting in a drastic fall in heat capacity and very rapid cooling. Thus the dependence on mass is quite complex.

The plot below shows some models of how the temperature (upper plot) will decrease versus age for white dwarfs of different mass. The main feature highighted by this plot is how more massive and dense white dwarfs reach the rapid Debye cooling phase first. (Note this plot was taken from a paper specifically discussing the evolution of massive white dwarfs. More typical 0.6 solar mass white dwarfs have not reached the Debye cooling phase after 10 billion years. I'm struggling to find cooling curves of temperature vs age for less massive white dwarfs, since it is almost always luminosity that is plotted).

The second question is about the density of a (cooling) white dwarf. To first-order, the density remains constant - white dwarfs do not shrink as they cool because they are supported by electron degeneracy pressure, which does not depend on temperature.

However, this is not quite true for young white dwarfs (less than say 100 million years old). These might have a "puffed up" envelope were the gas is only partially degenerate, or is not degenerate at all, and which does respond to temperature in the way you might expect. So a young, hot white dwarf will cool, get smaller and its average density will increase. I say average, because the core density of such a white dwarf will hardly change at all; it is really only the outer layers of the white dwarf that become more compact as they cool.