Nikon D40 has a Nikon F lens mount and currently there are 309 native lenses available for this mount. Beware that Nikon D40 doesn't have an internal focus motor so it will not auto focus with old-style screw-drive autofocus (AF) lenses. It still works well with modern Nikon AF-S, AF-I and G lenses but lenses form 1980s may not autofocus on Nikon D40.
Nikon D40 doesn't have a sensor based image stabilization system but 106 of these lenses already comes with optical image stabilization.
Since Nikon D40 has a APS-C sensor, it has a focal length multiplier of 1.5× so you have to multiply lenses original focal length with this multiplier to find the Full Frame equivalent focal length of the lens when mounted on D40.
You may also also be interested in these:
Nikon D40 Lenses with Image Stabilization
Nikon D40 Lenses with Weather Sealings