If the charge on the Y ion is -2, then the charge on the X ION WILL BE +2.
When two elements combine together to form a compound, they usually engage in chemical bonding in order to attain the octet form. Depending on the type of elements in the reaction, different chemical bondings are possible. In the question given above, a sign of -2 on the Y ion indicates that it has accepted 2 electrons from X, therefore, a sign of +2 will be on X because it has given two electrons to Y.