In an inelastic collision, kinetic energy is not conserved but the total energy and momentum remains conserved.
Momentum before collision = Momentum after collision
$m_{1} u_{1}+m_{1} u_{2}=m_{1} v_{1}+m_{2} v_{2} $
$\Rightarrow 4 \times 12=(4+6) v $
$\Rightarrow v=4.8 \,m s^{-1}$
Kinetic energy before collision $=\frac{1}{2} m_{1} u_{1}^{2}$
$=\frac{1}{2} \times 4 \times(12)^{2} $
$=288\, J $
Kinetic energy after collision $=\frac{1}{2}\left(m_{1}+m_{2}\right) v^{2} $
$=\frac{1}{2}(10)(4.8)^{2}$
$=115.2\, J $
$\therefore$ Loss in kinetic energy $=288 \,J -115.2 \,J$
$=172.8\, J$