Firstly we need to understand why the slab should move,well that is because when you will apply certain amount of force on the block of mass #M_1#,the frictional force acting at their interface will try to oppose the motion of the block and at the same time it will oppose the inertia of rest of the slab,that means,the slab will move because of the frictional force acting at thier interface.
So,let's see maximum value of static frictional force that can act is #mu_1M_1g=0.5*10*10=50N#
But applied force is #40N#,so frictional force will act by only #40N#,such that it will not allow the block to move,rather it will help the slab to move forward taking the block along with it.
So,accleration of the whole system will be# a=f/(M_1 +M_2)=40/(10+30)=1 ms^-2#
Now,if applied force was #100N#,static frictional force would have failed to stop the upper block from moving,in that case,maximum value of frictional force would have decreased to kinetic frictional force,i.e #mu_2*M_1g=0.15*10*10= 15N#
So,the slab would have been moving forward due to this amount of frictional force acting forward,so its acceleration would have been #a=15/30=0.5ms^-2#