1) Let's show this function is $1-1$. To do this, we suppose $f(n_1) = f(n_2)$ and show that this forces $n_1 = n_2$.
So, if it's true that $f(n_1) = f(n_2)$, then this means that
$$4n_1 + 1 = 4n_2 + 1 \\
\Rightarrow 4n_1 = 4n_2 \\
\Rightarrow n_1 = n_2 $$
and we have demonstrated what is required. Thus, $f$ is $1-1$.
2) Let's see if the function is onto (it might not be). If it is, we should be able to choose any $m \in \mathbb{Z}$ and show that there is some $n \in \mathbb{Z}$ such that $f(n) = 3n - 1 = m$.
If this is true, then we will need $n = \dfrac{1}{3}(m + 1)$. The problem is that this might not be an integer! For example, if $m = 1$, then $n$ would need to be $\dfrac{2}{3}$, which is not an integer. Thus, there is no $n \in \mathbb{Z}$ such that $f(n) = 1$ and so the function is not onto.
EDIT: For fun, let's see if the function in 1) is onto. If so, then for every $m \in \mathbb{N}$, there is $n$ so that $4n + 1 = m$. For basically the same reasons as in part 2), you can argue that this function is not onto.
For a more subtle example, let's examine
3) $f : \mathbb{N} \to \mathbb{N}$ has the rule $f(n) = n + 2$. If it is onto, then, for every natural number $m$, there is an $n$ such that $n + 2 = m$; i.e. that $n = m - 2$. Now, we don't have the same problem as we did before, that is, we don't have to divide by anything to solve for $n$. Thus there is always an integer $n$ so that $n + 2 = m$.
BUT! If $m = 1$ (for example), then $n$ would have to be $1 - 2 = -1$ which is not a natural number, so this function is not onto either.
The point of all this is, we have to look closely at both the domain and codomain to answer these kinds of questions.
Best Answer
So, they have the same cardinality. Let's rationalize this by enumerating the rationals.
Note that we can 'count' all the rationals like in this picture:
There is a small detail about removing repetition, but that's okay. Here, for example, we might count $1, 1/2, 2, 3,$ (skip $2/2$), $1/3 ,$ ...
This describes a function from $\mathbb{N} \to \mathbb{Q}^+$. In fact, it's a bijection, so it serves as a counterexample to both.