If an a.c. source is used in place of battery, the core of electromagnet will get magnetized, but the polarity at its ends will change. Since attraction of armature does not depend on the polarity of electromagnet, so the bell will still ring on pressing the switch.