The factory reset or hard reset for the Sony Xperia Z2 D6502 mobile phone can be done by software such as the PC companion software as well as the resetting of the mobile phone by menu or code. Note that by doing a reset by code or by menu will not backup your data and you will need to do this before you start the process.
You can backup your data and settings such as your APN settings and data with the PC companion software or by making a backup of your SIM card. This is shows elsewhere on this website. The software also allows you to make this backup of your data and settings. Note again that once the settings have been deleted as well as the data that you cannot recover these settings again and are completely gone and cannot be recovered.
Hard Reset will erase all of your data
All described operations you are doing at your own risk.
Hard Reset Sony Xperia Z2 D6502 with Menu
Hard Reset Sony Xperia Z2 D6502 by Code