B. $g$ need not be onto.
Let,
$A = \left\{0, 1, 2\right\}, B = \left\{0, 3, 4, 25\right\}, C = \left\{3, 4, 5\right\}$
$f = \left\{(0,3), (3, 5), (4, 4), (25, 3) \right\}$
$g = \left\{(1,3), (2, 4), (0,0)\right\}$ ($25$ in $B$ not mapped to by $g$, hence $g$ is not ONTO)
$h = \left\{(0,3), (1, 5), (2, 4)\right\}$
Now, $h$ is an onto function but $g$ is not.
$f$ must be an onto function as otherwise we are sure to miss some elements in range of $h$ making it not onto.