Let $X=\{1,2,3\}$, $Y=\{1,2,3,4\}$, and $Z=\{1,2\}$
(a) Define a function $g:X\rightarrow Z$ that is onto but not one-one
(b) Define a function $h: Y\rightarrow Y$ that is neither one-to-one nor onto
for (a) suppose we define $g(1)=1,g(2)=2,g(3)=2$ Is right ?
for (b) $h(1)=h(2)=h(3)=h(4)=1$ Is right ?