The axle assemblies as a whole can be interchanged. Now the joints on a 2wd axle are smaller then the joints for a 4wd axle, so keep that in mind.
Now if you are wanting to take the CVJ (inter joint) from the 2wd axle and put it onto the shaft of the 4wd axle, that can be done but you will need to use the joint boot for a 2wd. The same goes for the DOJ (outer joint)