The easiest way would probably be to shell out:
This will work in other programming languages as well.
/usr/bin/canberra-gtk-play will play a sound from the current sound theme. See the freedesktop.org sound naming spec for a list of available sounds and their meanings. Beware that (as far as I know) there isn't a sound theme that provides all of these sounds.
ls /usr/share/sounds/ubuntu/stereo to see what sounds are supported by the 'ubuntu' sound theme which is default, and rarely changed (due to no easy way to install sound themes) on Ubuntu.