Every camera has it's own mount and lenses do not fit.
You can not put a Sony lens on a Nikon without an adapter. But, remind, adapters do not transmit electronic functions and an adapter will allow you to mount it but you need to focus manual. AF is then out of game.
Best is to get a Nikon F mount lens, doesn't matter the brand.
Main Brands like Sigma, Tokina and Tamron build lenses for all bodies what ever the brand is and you will easy find on that fits in the shop where the Sony comes from.
There are other lens brands like Cosina that is indeed a Zeiss owned company that builds Sony Zeiss lenses as well, then there is Quantaray that is a hybrid name for Sigma lenses, Vivitar that is to avoid cause bad quality.
Best in the whole line is Tokina, sharp as a razor and built like a Tank but limited in selection and ranges. Their 11-16/2.8 wide angle is the world's sharpest lens ever made. The 12-24 has a solid reputation as well. But watch out, the D40 only autofocuses with HSM motorized lenses and Tokina doesn't has any despite of the fact that Tokina lenses are easy to use with manual focus.
So, run to the shop but first know what you need. Superzoom, get a Tamron 18-270 VC HSM, 50 mm kind wide open, the Sigma 30/1.4HSM is a real hammer, mid range Nikon 16-85 VR and affordable tele, the 70-200D VR from Nikon, Makro the Nikon 105/2.8. VR. Note that all Nikon VR lenses are HSM.