Ok well assuming that firing a gun will attract more zombies, a silencer is a must otherwise any firearm will probably attract more zombies than it kills.
Unless you are already trained and proficient with a handgun, I would not recommend using one. They are not that easy to aim and even harder to use properly under high stress situations. (IE being rushed by 8 zombies and you only have 10 rounds) It may make you feel safer, but odds are when you really need it, you won't hit a damn thing.
Long range fire arms are not recommended as well for the same reason. They are also very loud, so unless you are already proficient with one, you probably will attract more zombies than you hit.
[NOTE: If, as in Walking Dead, you find yourself on an isolated farm with time on your hands, you can take the opportunity to train yourself in the use of these weapons. However you will need a lot of surplus ammunition to get yourself trained up.]
I think a sub-machine gun with a silencer is the best way to go. It is quiet and so long as you know how to load and point it, you will probably hit something. The silencer should keep you from alerting other zombies.
Although as far as I know, sub-machine guns are illegal, even in the United States, so you will have to raid the local police station after it is overrun by the zombies to get one. Be sure to pick up lots of ammunition while you are there, cause you will burn though it like crazy when you have to use it.