Yes, unless there is some strange ground loop between the 9V adapter and the power supply of your PC used for programming. The safest way is to use a laptop for programming on battery power. Never plug in its power supply (or any other plugs) while plugged into the Mega.