A layer 2 switch doesn't use the global gateway for routing any traffic. It's only used when you use the switch to ping something or telnet into it, things like that. Since it's layer two it doesn't really care about ip addresses in the routing since. The ip address of the switch, subnet and global gateway are just like your computers address.
With traffic fromm other devices it uses the arp request and Mac address table. A computers requests it's own gateway if it tries to talk out side of its own subnet. The layer 2 switch doesn't do any of that.
As far as multiple vlans talking to the switches ip addresses, it works just like your computer. You can use diffrent subnets to get to diffrent subnets if there is a router. If you do not have a router I found that only vlan 1 works switch to switches with a 2950. Switches that let you change the management vlan can choose which vlan is that "primary" usable network.
This question did intrigue me and I thought it might help others to do some tests and show the results so I came to the above conclusion by testing it. I took my virtual setup and tested this because I had more than one way it could work in mind. My findings were a little diffrent than I expected when no router is used.
Test 1 I used two older Cisco 2950s. I set up vlan 1 and vlan two. I set vlan 1 192.168.10.1 and 10.2 on second switch. I set vlan 2 192.168.20.1 and 20.2. I plugged a pc into a vlan 1 and 2 port on each switch so the vlans would go up up on both switches. I tried this experiment with a single trunk cable between them and also tried with two cables on access ports. One cable carried vlan 1 and one cable carried vlan 2. Results were the same either way.
Result 1.. from the switch I could ping both of "my" addresses. I could ping the remote vlan 1 address but not vlan 2 address.
Test 2 With the same setup I thought if I set a global gateway address of 192.168.20.50 it would force vlan 2 to be the usable subnet. Remember, I do not actually have a router in this test.
Result 2. The switch still pinged vlan 1 local and remote. It did not ping the remote vlan 2. So, by putting a global gateway as vlan 2 it did not change how the switch reacted.
Test 3 I introduced a router and 3 subnets. I had 126.96.36.199, 20.50 and 30.50. On the switch I connected to I had 192.168.10.1, 20.1, 20.2. Global gateway was not set.
Result 3 From the switch I could ping all 3 router address.
Test 4 I disabled vlan interface 3 on the switch.
Result 4 I could no longer ping 192.168.30.50 on the switch since it didn't have a directly connected interface.
Test 5 I disabled vlan 1 to see if vlan 2 could still ping with no vlan 1.
Result 5 Ping on vlan two to 192.168.20.50 worked fine.
Test 6 I enabled vlan 1 and added a default gateway of 192.168.20.50 (vlan 2s gateway) I left interface vlan 3 disabled.
Result 6 The switches was able to ping 188.8.131.52 ( a subnet not currently up on the switch) with no issue. Even though the default gateway was on vlan 2s address I can still ping any viable address the router can get too.
That's enough for now. If you get a chance to get the network simulator packet tracer it's great for testing things. Some people share it on www.4shared.com packet tracer 6.1 you get it free when going to a Cisco class.