.
Let x = be the number of boys in the class, and y be the number of girls.
Then you have two equations:
=
,
x + y = 42.
Express x via y from the first equation: x =
, and substitute it into the second equation.
You will get a single equation for the unknown y:
+ y = 42.
Multiply both sides by 4 and simplify.
4y + 3y = 42*3 = 126,
7y = 126,
y =
= 18.
Now x =
=
= 24.
Answer. There are 24 boys and 18 girls in the class.