+1 True. But in a larger sense, the number of pixels can effectively be reduced, such as when lenses designed for smaller sensors are mounted and extreme vignetting occurs. The D40 has a full size sensor (24 x 16 mm), which makes such a scenario plausible (but I don't know whether it's actually possible: that depends on lens mount compatibilities).
–
whuberJan 23 '12 at 23:02

1

@whuber: What exactly do you mean by "full size" sensor? I don't read that to mean "full frame" sensor...but I'm not really sure exactly what it means. Its still an APS-C sensor, correct? The only time APS-C sensor sizes change, as far as I know, is when you change brands...Nikon APS-C is always the same size amongst Nikon, but different than Canon APS-C size.
–
jrista♦Jan 23 '12 at 23:22

This answer is true but unhelpful. I'm reminded of the joke about the engineer and the hot air balloon.
–
mattdmJan 24 '12 at 1:03

@jr I mean in a practical sense as implied by the context: cameras tend to come in product lines which frequently share many lenses, but whose sensors may differ in dimensions (as well as pixel size). A lens will usually create an image within a circle beyond which there is severe light falloff. In some camera lines it is possible to mount a lens designed for a physically smaller sensor on a camera having one of the larger sensors for that line: this is the sense of "full size." In these situations the lens can work effectively but the image it makes will not cover the entire sensor.
–
whuberJan 24 '12 at 5:24

@whuber if you call APS-C in Nikon F-mount line "full size", what would the full-frame sensor of D3 and D700 (where you can also mount DX lenses) be called?
–
ImreJan 24 '12 at 8:20

As @ahockley said, the resolution (number of megapixels) is determined primarily by the sensor, so changing the lens doesn't change it.

Being fair, the resolution of the sensor is basically the theoretical maximum of which the system as a whole is capable. Although a better lens can't increase it, a really poor quality lens could reduce the effective resolution below that. In your case, however, that's fairly unlikely short of using a really poor quality lens. The reason for this is fairly simple: most lens designs can easily produce an image of higher resolution than the sensor you're using.

The times you could run into resolution limitations from the lens would be with a really low-end, off-brand lens -- if somebody's offering a 500mm lens for $50, chances are pretty good that it will be the limit on resolution. Likewise, if you hook the camera up to a low-end telescope or microscope, something in some other mount (e.g., C-mount) that was never designed for that size of sensor. That generally won't happen by accident though -- you'll generally have to find and such adapters to mount them on the camera at all.

A reasonably recent, undamaged lens from Nikon or any of the reasonably reputable 3rd party vendors like Sigma, Tamron, or Tokina shouldn't have much difficulty producing pictures at the full resolution of the sensor.

No, it does not. The resolution is a characteristic of the camera body and does not change with the lens.

However, there is one exception (which does not apply to you, since the Nikon D40 is a DX-format camera): if you mount an APS-C or DX format lens onto a full-frame or FX-format camera, the pixels outside the APS-C or DX area may not be usable due to vignetting, resulting to a loss of resolution due to cropping. On Nikon, it is possible to force FX format image capture with a DX-format lens, but this often results in severe vignetting that will force you to crop to a smaller image. On Sony, unless you are using a third-party lens, this is not an option and the 24-megapixel sensor on the A900 and A850 will be limited to the 11-megapixel APS-C crop area.