Virtually any lens u can mount on nikon cameras u can mount on D40. Its just a matter of whether you can have metering and autofocus or not.
I'm using a manual focus 50mm f1.4 and a 100-300mm Cosina lens bought from cash converter due to budget issues... works pretty well just that you cant have autofocus and metering sometimes when you needed it....