Empirical formula gives us ratio of the number of atoms in a compound. In this case we only know that ratio of carbon atoms to hydrogen atoms is 1:2 but we don't know the exact number of atoms in the compound. Thus the molecular formula could be `CH_2` (unlikely because that would leave carbon with two unpaired electrons), `C_2H_4,` `C_3H_6` etc. or more generally `C_nH_(2n).`
To get the exact molecular formula we must use molar mass of the compound. To get molar mass of a compound we simply add molar masses of all the atoms in the compound.
Now we calculate molar mass of `CH_2` :
`M(CH_2)=12.011+2\cdot1.008=14.027 g mol^(-1)`
To get `n` from our molecular formula we simply divide molar mass of compound 112 by molar mass we obtained 14.027.
Now we just insert the obtained `n` into the molecular formula above. Hence, the molecular formula of the compound is `C_8H_16.`
Note: Molar mass of an atom is atomic mass of an element (which you can read from the table of elements) multiplied by 1 g/mol (e.g. molar mass of an hydrogen atom is 1.008 g/mol).