The system shown in the figure is released from rest. The spring gets elongated
(Neglect the friction and masses of pulley, string, and spring.)
Let spring does not get elongated, then net pulling force on the system is or simply Mg. Total mass being pulled is . Hence, acceleration of the system is
Now since a < g, there should be an upward force on M so that its acceleration becomes less than g. It means there is some tension developed in the string. Hence, for any value of M spring will be elongated.