Solution:
Concept: Silver nitrate tests the anion: a white precipitate soluble in ammonium hydroxide is silver chloride. Sodium hydroxide tests the cation, by the colour of the metal hydroxide it precipitates.
Step 1 — (a) Find the anion.
The white precipitate with silver nitrate dissolves in ammonium hydroxide, so it is silver chloride and the anion is chloride, Cl−. It dissolves because it forms a soluble complex with ammonia.
CuCl2+2AgNO3→2AgCl↓+Cu(NO3)2
AgCl+2NH4OH→[Ag(NH3)2]Cl+2H2O
Step 2 — (b) Find the cation.
A pale blue precipitate with sodium hydroxide is copper (II) hydroxide, so the cation is copper (II), Cu2+.
CuCl2+2NaOH→Cu(OH)2↓+2NaCl
Putting the two ions together, salt Y is copper (II) chloride, CuCl2.

Watch out: A white precipitate that dissolves in ammonium hydroxide is read as silver chloride; the full test also shows it does not dissolve in dilute nitric acid, which rules out a carbonate or a sulphite.
Therefore, (a) the anion is chloride (Cl⁻) and (b) the cation is copper (II) (Cu²⁺).