The correct option is D +1 and +2
O2F2 :
Since fluorine is more electronegative than oxygen so, oxidation state of fluorine is −1 in all its compounds. Let oxidation number of O atom in O2F2 is x.
2×x+1×(−1)=0x=+1
−1F−+1O−+1O−−1F
So, oxidation number of oxygen will be +1 as calculated.
OF2:
Let y be the oxidation state of "O" in OF2.
Since the overall charge of a neutral molecule is zero. The sum of oxidation states of all elements in it should be equal to 0.
Therefore, y+2(−1)=0y=+2
Hence, the oxidation state of "O "in OF2 is +2.