This is invalid, because 'a man hour' (when A is the man) is more valuable than 'a man hour' (when B is the man), so you can't just do a straight average of 40 'A hours' with 56 'B hours' to get 48 'generic hours'.
The correct method is the one used by Nick Wedd:
A and B together finish in 24 hours, so they do 1/24 of the job every hour.
A by himself finishes in 40 hours, so he does 1/40 of the job every hour, and B must do (1/24 - 1/40) of the job every hour. This works out to (5/120 - 3/120 = 2/120 = 1/60), so B by himself would finish in 60 hours.
Here's another way to look at that invalid method:
Suppose A and B start at the same time, intending for each to do half the job. After 20 hours, A has finished his half; B has 10 hours left on his.
Suppose A quits, and C shows up and starts helping B with the remaining portion, and C works at the same speed as B. Obviously they will cut that 10 hours in half, making it 5 hours. (Averaging 'B hours' and 'C hours' *is* valid, because they are equally valuable.)
Now suppose that the same things happen, except that C works as the same speed as A (and faster than

. They will cut down the 10 hours by *more* than half; it turns out that they will cut it down to 4 hours.