Your D40 (like almsot all digital cameras) has an anti-aliasing filter, which is there to stop the jagged edge effect that digial can give on clearly defined lines. The net effect is a more natural looking image but it will also make it slightly softer too, so the vast majority of digital images will require some sharpening to make them look right. If you want to know more have a look here -
http://en.wikipedia.org/wiki/Anti-aliasing
That said the AA filter may not be the only cause of the softness you are seeing. Clearly not all lenses are equal, and the kit lenses that ship with entry level DSLRs are not the sharpest. I know the Canon 18-55 kit lens is often slagged off for being soft but with a bit of work it can deliver good results, as Duncan mentions stopping down and bit and using a tripod will almost certainly improve things.