I used the D40 for 2 years and the gf still has one, use it regularly. All the Nikkor F-mount lenses
ever made will fit; but only the more modern AF-S ones will autofocus (which wont be an issue as youd only ever want to buy perhaps the 18-200 or the 10 (or 12)-24 zooms to use with it and theyd be fine).
The only reasons I sold it were because the D90 has a bigger rear screen and works more quickly (but its more bulky and somehow more cramped, the D40 just fits easily).
The little 18-55 lens it comes with is a bargain too, very sharp.