.
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.
3y + 4y = 42*4 = 168,
7y = 168,
y =
= 24.
Now x =
=
= 18.
Answer. There are 18 boys and 24 girls in the class.