Note that (g∘f)(x)= g(f(x)). So if f is onto, then it means for all y∈Y there exists an x∈Xsuch that y=f(x). Since g is onto, it also meas that for all z∈Z there exists a y∈Y such that g(y)=g(f(x))=z. Thus, for all z∈Z there exists an x∈X such that g(f(x))=z. Hence g∘fis onto
One important is that g∘f is still onto even if f is not onto but g is onto. In other words g must necessarily be onto for g∘f to be onto.