For the information given in the statement you have
[tex]\frac{\text{ number of males students}}{\text{ total number of students}}=\frac{16}{40}[/tex]Simplifying
[tex]\frac{16}{40}=\frac{8\cdot2}{8\cdot5}=\frac{2}{5}[/tex]Therefore, the fraction of boys in the class is
[tex]\frac{2}{5}[/tex]