Now, about 4^3 ways. This comes from any of the FOUR balls in boxes. Say balls are A, B , C and D, while boxes are X, Y and Z. For A in X, any of A, B, C, and D in Y and again any of A, B, C, and D in Z. But can the same ball A be there in all three boxes.....NO. But in case of 3^4, can same box X, have all four balls...YES. I hope it clears the query on why 3^4 and not 4^3.
Nullbyte
@chetan2u, can you explain what happens in this case pls?
Nullbyte, that will not be correct. you are just filling three balls, what about the fourth one? Here, you will have to tak ethe possible combinations of boxes. It will be 1, 1, 2: Choosing the box with 2 balls can be in 3C1 or 3 ways. Next selecting/choosing 2 balls from 4 will be in 4C2 or 6 ways and then selecting one ball from the remaining two balls in 2C1 way and the remaining ball will go in the final box in 1C1 way.....3*4C2*2C1*1C1 = 3*6*2*1 = 36 ways.