All rings here are commutative with a unit, and ring homomorphisms satisfy the axioms below.
If you require that $\varphi : \Bbb{Z} \longrightarrow \Bbb{Q}$ satisfies $\varphi(xy) = \varphi(x)\varphi(y),$ $\varphi(0) = 0,$ $\varphi(1) = 1,$ $\varphi(x + y ) = \varphi(x) + \varphi(y)$
then it is a theorem in mathematics that there is only one ring homomorphism from $\Bbb{Z}$ into any other ring. This is because we just extend additively from the fact that $\varphi$ is completely determined in this case by the image of $1$. There are many answers above that tell you how to do this, what I will do know is show you how we can apply these methods to prove that:
1) The only non-trivial ring homomorphism from $\Bbb{Q}$ to itself is the identity map.
It is clear that if $\varphi$ is such a ring homomorphism, it has to fix the integers by the same reasoning as above. So we now just need to check that $\varphi(1/n) = (1/n)$ for all non-zero integers $n$. But this follows immediately because
$\begin{eqnarray*} 1 &=& \varphi(1) \\ &=& \varphi\left(\frac{1}{n}\cdot n \right)\\ &=& \varphi\left(\frac{1}{n} \right) \varphi(n) \\ &=& \varphi\left(\frac{1}{n} \right)n \\ \implies \frac{1}{n} &=& \varphi\left( \frac{1}{n} \right) \end{eqnarray*}$
which proves the claim.
2) The only non-trivial ring homomorphism $\varphi$ from $\Bbb{R}$ to itself is the identity map.
We claim that for any $x\geq 0$, $\varphi(x) \geq 0$. To see this write $ y =\sqrt{x}$ for where $y \geq 0$. Then
$\begin{eqnarray*} \varphi(x) &=& \varphi(y^2) \\ &=& \varphi(y)\varphi(y) \\ &=& \bigg(\varphi(y)\bigg)^2\\ & \geq & 0 \end{eqnarray*}$
showing our claim. In fact it is not hard to see from here (exericse) that if $x \leq 0$, $\varphi(x) \leq 0$. Now suppose we take any $x \in \Bbb{Q}$ and suppose that $\varphi(x) \neq x$. We show that $\varphi(x) > x$ and $\varphi(x) < x$ cannot happen. For the first case suppose that
$\varphi(x) > x.$
Then by the density of the rationals in the reals there is a rational $\frac{m}{n}$ in between $\varphi(x)$ and $x$. Write $\varphi(x) > \frac{m}{n} > x$. Then we can get two inequalities, that is $x - \frac{m}{n} < 0$ and $\varphi(x) - \frac{m}{n} >0$. Recall from the first problem above that any non-trivial ring homomorphism on the rationals is the identity. Furthermore any ring homomorphism on $\Bbb{R}$ becomes one on $\Bbb{Q}$ simply by restriction of the domain. It follows that
$\varphi(x) -\frac{m}{n} = \varphi(x) -\varphi \left(\frac{m}{n} \right) = \varphi\left(x - \frac{m}{n} \right) > 0. $
However we now get a contradiction becuase $x - \frac{m}{n}<0$ so by the result that I stated as an exercise earlier in this problem, $\varphi(x - \frac{m}{n}) < 0$. Hence we cannot have that $\varphi(x) > x$, similarly we cannot have that $\varphi(x) < x$. Done!
I hope the problems I have mentioned above have strengthened your understanding of using methods that others have shown you.