\year does not just give a number; it gives an internal integer. This is one of the types of integers that TeX knows. Together with the denotation integers (these are just strings of digits, possibly converted between bases) they are known as the normal integers. Besides the normal integers there are also coerced integers, which occur when an internal glue or dimen is coerced to an integer.
TeX goes implicitly from a string of digits to a number, that is, if TeX expects a number then anything that looks like a number is accepted. So 42 is a number. The other way around has to be done explicitly though, either through
\number. When we are dealing with an internal integer,
\the is equivalent to
\number. Since you ask what you can use for
XXXX when you want
\theXXXX to print something, the answer is an internal integer. There are quite a lot, the ones that you can easily influence are tokens defined by
mathdef and the contents of
For non-internal integers you want to use
\number instead though. That is to say,
\number123 will compile fine, where
\the123 will fail.