I am playing my bass for the first time in two years. I got it out yesterday to prepare and the g-string was loose. Should I change the strings? It has been stored in its hard case and indoors. Please let me know.
Check the tuning machine operation (is the tuning key and/or cylinder, post loose or have a lot of play?), string properly wound around the post? Check the nut and bridge components. Also depending how it was stored...temperature and humidity, even indoors, will greatly affect the overall instrument.
You can of course first try to tune up that old string first, but I'd say it certainly can't hurt to replace the strings. After two years they will inevitably have corroded at least somewhat, both on the surface and the cores, and that affects tone, playability, intonation and makes it more likely that one will break at an inconvenient time. Bass strings aren't as cheap as guitar ones, but they're still not too expensive (compare to good e.g. cello or double bass strings), so it's probably a worthwhile investment.