Let us say cart A has 4kg mass and 5m/s velocity and running at `rarr` direction.
Cart B has 3kg mass and 4m/s velocity running at `larr` direction.
Let us assume once they stick the combination runs at `rarr ` direction with a velocity of V. The mass of the combination would be (4+3) = 7kg.
Momentum of masses before stick
`= rarr 8`
Momentum of the masses after stick
`= rarr 7V`
It is given that the carts are travelling on a frictionless track. Also here we have to assume that at the moment of sticking there is no energy loss by noise or vibration or heat.
Assuming the above conditions we can say that final momentum is equal to initial momentum.
momentum before stick = momentum after stick
`rarr 8 = rarr 7V`
`V = rarr (8/7)`
`V = rarr 1.17m/s`
So the final velocity of the system would be 1.17m/s at the initial direction of the 4kg mass.