Let the total distance it covers be 2x
Time taken to cover the first half of distance t1= x/40
Time taken to cover the next half of distance t2= x/60
Total time taken = t1 + t2
= x/40 + x/60
= 100x/2400
=x/24
Average speed = total distance/total time taken
= 2x/(x/24)
= 48x/x ms-1
= 48 m/s
Hope it helps...