Let the rate downstream of boat be u kmph. Its rate upstream = v kmph. According to the question,
u60+v20=4 and,
u40+v40=6 ⇒u20+v20=3 By equation (i) - (ii),
u60−u20=4−3 ⇒u40=1 ⇒u=40kmph From equation (i),
4060+v20=4 ⇒v20=4−23=28−3 ⇒v20=25⇒v=520×2 =8kmph ∴ Speed of current
=21(u−v) =21(40−8)kmph=16kmph 
Let
Speed of boat = b kmph
Speed of current = w kmph
According to the question,
b+w60+b−w2=4
.....(i)
and b+w40+b−w40=6
b+w20+b−w20=3
From equation (i) – (ii),
b+w60−b+w20=1
b+w40=1
b+w=40
Now from equation (i),
4060+b−w20=4
b−w20=4−23
b−w=8
Solving equations (iii) & (iv)
b = 16 kmph