Let the number of boys be B and the number of girls be G.
From the ratio, we have B:G=3:2.
Let B=3x and G=2x.
Since the total number of students is 40, we have:
3x+2x=40
5x=40
x=8.
Thus, B=3×8=24 and G=2×8=16.
The total marks scored by boys is 24×42=1008 and by girls is 16×46=736.
The total marks for the class is 1008+736=1744.
The average marks for the whole class is:
401744=43.6.
Therefore, the average marks scored by the whole class is 43.6.