Are the o2 senser interchangeable? (front + rear)

I need a new after cat o2. I have a extra befor the cat o2. can i use that???