According to Siddiqui, a former Engineering Technician at Apple (company).
Here is what happens.
If you bring your device to a Genius Bar and it gets replaced, then your phone goes back to AppleCare. It is then analyzed to confirm the FRS/Genius’ diagnosis (diagnostic accuracy is a measured metric for AppleCare personnel like Genii and Technicians). Once this happens, the battery and enclosure are recycled.
The remaining major components are stress tested—the camera module, receiver, speaker, microphones, logic board, etc. Those that pass the testing are then cycled back into the service inventory channel and used as service parts or used to build service replacement devices.
The battery and enclosure on the service replacement devices are always new.
The device you receive as a service replacement is never someone else’s phone that Apple has repaired, shined up, and sent to a store. No, it is especially constructed just for you, it’s been very thoroughly tested (more than new inventory that’s sold in the store) and the only components it may have that are not new are the logic board and other internal components—it may be as few as one or as many as three or four major components. Or, maybe there haven’t been enough available parts and AppleCare starts getting new units to use as service replacements until parts are available again.
That is the luck of the draw, unfortunately.
If you bring in your phone to recycle towards credit for a new device, that’s processed by a third party company and has nothing to do with AppleCare or service replacements.
Source: Quora