Two coils A and B of insulated wires are kept close to each other

Two coils A and B of insulated wires are kept close to each other. Coil A is connected to a battery through a key. What would happen if :
(i) a current is passed through coil B by plugging the key, and
(ii) the current is stopped by removing the plug from the key?
Explain your answer mentioning the name of the phenomena involved.

(i) The galvanometer connected to coil A shows a deflection, i.e., current passes through
coil A as well.

(ii) The galvanometer connected to coil A again shows a deflection, this time, however, in the opposite direction, i.e., a current passes through coil A in the opposite direction. The observations are made because whenever we change the current in the coil B, the magnetic field associated with it and the coil A in its proximity changes. At the very instant of plugging the key in or taking the plug out, there is an instantaneous flow of current and a change in the magnetic field associated with the coil B. During this instantaneous moment, the current in coil B reaches from zero to the maximum or from the maximum to zero. This changing magnetic field of coil B induces a current in the coil A.

The phenomenon is known as electromagnetic induction.