As the spring is stretched, it exerts an upward restoring force f. At maximum extension, Newton's second law gives
∑ F = f - mg = 0 ==> f = (2.0 kg) (9.8 m/s²) = 19.6 N
By Hooke's law, if k is the spring constant, then
f = kx ==> k = f/x = (19.6 N) / (0.15 m) ≈ 130 N/m
A 4.0 kg mass would cause the spring to exert a force of
f = (4.0 kg) (9.8 m/s²) = 39.2 N
which would result in the spring stretching a distance x such that
39.2 N = (130 N/m) x ==> x = (39.2 N) / (130 N/m) ≈ 0.30 m ≈ 30 cm