2) B
This question deals with valencies.
X, being in group 3, has a valency of +3. It has 3 electrons in its outer shell. It needs to donate its 3 electrons to be stable.
Y is in group 6, meaning it needs 2 electrons to be stable. Its valency is -2.
To find the formula we can use the following technique:
X Y
X
+3 -2
The big X is a criss cross, meaning -2 goes to X and +3 goes to Y.
So the formula is X₂Y₃.