Also, depends on mileage not years--an old, unridden bike will be fine. You can usually get ~3k miles from a chain without having to change the cassette (the cluster of gears in the back). If you let the chain go too far, it stretches, which wears the cassette out more quickly, then you need to change both. You can judge chain wear objectively by measuring the distance between chain links.
My daily bike doesn't have have indexed gears (it doesn't click when you shift), which will last longer. I use fairly cheap chains/cassettes, and just replace both every 10k miles or so. Simpler.