How does an android factory reset work? When performing a factory reset, does Android remove all the added applications and user data or does it completely reflash an image of the OS

I am running on jelly bean 4.3 stock
When performing a factory reset:


/system is untouched since it's normally read-only anyway
/data is formatted
/cache is formatted
/sdcard is not touched unless you specify. Note that apps on the sdcard will still be erased.


So, to answer your question, the system is not reflash end, but instead the data and cache partitions are formatted.