We have 4 elements in set B and 5 elements in set A and surjection means every element in B must be mapped to. So, this problem reduces to distributing 5 distinct elements (r = 5) among 4 distinct bins (n = 4) such that no bin is empty, which is given by n! S(r, n), where S(r, n) is Stirling's number of 2nd kind. So, here we need S(5, 4).
We have S(r+1, n) = n* S(r, n) + S(r, n-1)
1
1 1
1 3 1
1 7 6 1
1 15 25 10 1
So, S(5,4) = 10 and 4! = 24 giving, number of surjective functions = 24 * 10 = 240
Ref: See Theorem 9:
http://www.cse.iitm.ac.in/~theory/tcslab/mfcs98page/mfcshtml/notes1/partset.html