Answer
a) $392\;\rm N/m$
b) $17.5\;\rm cm$
Work Step by Step
a) Let's assume that the stretching of the spring due to its own weight when suspended from the ceiling is negligible.
After attaching the 2-kg mass, the spring stretched 5 cm and stopped.
This means that the net force exerted on this 2-kg mass is zero since it is at rest.
$$\sum F_y=F_{sp}-mg=ma_y=m(0)=0$$
Hence,
$$F_{sp}=mg$$
We know that the spring force is given by $-kx$ where $x$ is the stretched or compressed distance.
Thus,
$$-kx=mg\tag 1$$
Thus, the spring constant is given by
$$k=\dfrac{mg}{-x}$$
Plugging the known and recall that the spring with the block stretched down its equilibrium point by 5 cm, so $x=-0.05$ m.
$$k=\dfrac{2\times 9.8}{-(-0.05)}=\color{red}{\bf 392}\;\rm N/m$$
---
b) Now we know that the mass attached is now a 3-kg mass.
Using (1) to find the stretched distance below the equilibrium point. Then we can find the final length of the spring
$$x=\dfrac{mg}{-k}$$
Plugging the known;
$$x=\dfrac{3\times 9.8}{-392}=-0.075\;\rm m=\bf -7.5\;\rm cm$$
The negative sign is due to the direction.
Then the final length of the spring is
$$L_f=L_i+|x|=10+7.5=\color{red}{\bf17.5}\;\rm cm$$