Oxygen always has an oxidation number of oxygen is -2 and that of carbon is unknown so we say x

The equation will be then

2x+4x (-2) =-2

2x=+6

X=+3

Oxidation number of carbon then is +3.

The oxidation number of the carbons + the oxidation numbers of the oxygens must equal -2. That of oxygen will always be -2 save in water which is -1 and of2 where it is +2. For the carbons its oxidation number has to be +6. In this equation there are 2 carbon atoms, each should give +3 each.

In this molecule the oxygen atom overall charge can also be calculated like this; Since there are 4 atoms.

The overall charge of the atom would be

4 x(-2) = -8

And that of carbon would is +3