What happens to my world when a Minecraft mod is uninstalled or overwritten?

Solution 1:

The world will just generate with air blocks replacing non-vanilla blocks, and your non-vanilla items will just disappear. Re-installing the mod will not bring the blocks or items back, unless you do so before loading the world again.

(As a side note, some mods used to render your world unplayable unless the mod was installed again, I'm pretty sure Notch fixed it though, but there might be a few that mess things up.)

Solution 2:

The mod will make new item IDs, and items are stored by the item IDs. So, for example, I once had the portal gun and I updated the mod and I had a melon stem in one of my chests :). Any other items or blocks are just not there!