Answer
(a) Yes
(b) No
Work Step by Step
(a) Yes it is possible for $f(1)=5$ and $f(2)=5$ since every element of $x$ is assigned to exactly one element in a set $B$ which can also be called $f(x)$.
(b) No it is not possible for $f(1)=5$ and $f(1)=6$ because the element $1$ in a set $A$ is assigned to two elements in a set $B$ hence defies the definition of a function.