DX refers to a crop sensor - like your d40 has. Its smaller then a traditional 35mm piece of film at 24 x 16 mm (there are other size to) where as a FX or full frame sensor is the same size as a 35mm piece of film at 35 x 24 mm.
Some lenses are marked as DX, which means they project an image circle that matches the smaller sensor size and which may cause vignetteing on FX sensors. FX lenses always work with DX
There's pros and cons to both as a search on here will show, but FX is always much more expensive
Hugh