The D40 is quite a colourful little camera in its normal settings, but if you want to crank a bit more out of it, go to Optimize Image in the shooting menu and select Custom. Set colour mode to IIIa and saturation to + . Leave the other settings as they are, or your colours will go a bit squiffy.
Nikons of that generation will often over-expose ever so slightly, which will take some of the richness out of the colours, so set your exposure compensation to about -0.7
The other big factor will be the weather. On a nice bright sunny day, you'll get nice bright colours. On a manky dull day, you'll get manky dull colours.
If possible, position yourself so that the sun is behind you, or off behind your shoulder for maximum colourfulness.