The function $f$ must be onto and need not be one-to-one.
The function $g$ must be one-to-one and need not be onto.
For Example: Let $A = \{ 1,2 \}$, $B = \{ a \}$ ; Take $f(1) = a. f(2) = a, g(a) = 1$ ; So, $f $ need not be one-one and $g$ need not be onto.