Typically when you buy a domain name, the company you registered with enters dns records for your domain with their dns server(s). Typically you are given an account to login and change certain dns records (A record, cname, mx record etc.).
Typically you would set the A record for your FQDN (fully qualified domain name) to your root domain, or root server, depending on your domain design.
So, if you have a single server, you might set the A record for your domain to the the IP of that server, and then alias
www.yourdomain.name to yourdomain.name.
It's the DNS server that is the magic. You can set the hostname of your server to www.yahoo.com, but no one would find your server, since the yahoo has registered that name.
try:
nslookup www.yahoo.com
or:
dig www.yahoo.com
and finally:
whois www.yahoo.com
hope that helps,
-al