For first 30km, speed of car is 40km/hr
Then, time taken to travel the first 30 km, t1=distancespeed=3040=0.75hr
For next 30km, speed of car is 20km/hr
Time taken to travel the next 30 km ,t2=distancespeed=3020=1.5hr
Total distance travelled = 30 + 30 = 60 km
Total time taken = 0.75 + 1.5 = 2.25 h
Average speed = Total distance covered / Total time taken
Average speed = 60 km/ 2.25 h
= 26.67 km/h