D40's kit lens, the 18-55mm DX II, is very sharp at f/5.6 to f11 regardless of the focal length, as the
review at photozone.de shows. Nikon's new consumer lenses show improved sharpness over their previous versions (and not only the sharpness is better)... this gives me hope that the other new lenses rumored to be announced later this year will also have improved characteristics over their previous versions...
However, as a general rule, lenses need to be stopped down 1 or 2 stops from their max aperture (which may vary with focal length in all but pro zooms) to get to their sweet spot where sharpness and contrast are at their best across the frame. For a consumer lens that has max apertures in the range f/4-f/5.6 the sweet spot is therefore in the range f/8-f/11...
When talking about portraits, sharpness is not always important though... many prefer skin and faces to be a little softer. There are even "soft focus" filters that you can use to get softer portraits (and not only! - you can get dreamy landscapes and flowers too). These filters were used a lot in glamour photography with film cameras... you can get similar effects in Photoshop now...
Darrin