When you heat a whole egg, its protein molecules behave exactly as they do when you whip an egg white. They unfold, form new bonds, and create a protein network, this time with molecules
of water caught in the net. As the egg cooks, the protein network tightens, squeezing out moisture, and the egg becomes opaque. The longer you cook the egg, the tighter the network will
be. If you cook the egg too long, the protein network will contract strongly enough to force out all the moisture. That is why overcooked egg custards run and why overcooked eggs are rubbery.
If you mix eggs with milk or water before you cook them, the molecules of liquid will surround and separate the egg’s protein molecules so that it takes more energy (higher heat) to make the protein molecules coagulate. Scrambled eggs made with milk are softer than plain scrambled eggs cooked at the same temperature.
When you boil an egg in its shell, the air inside expands and begins to escape through the shell as tiny bubbles. Sometimes, however, the force of the air is enough to crack the shell. Since there’s no way for you to tell in advance whether any particular egg is strong enough to resist the pressure of the bubbling air, the best solution is to create a safety vent by sticking a pin through the broad end of the egg before you start to boil it. Or you can slow the rate at which the air inside the shell expands by starting the egg in cold water and letting it warm up naturally as the water warms rather than plunging it cold into boiling water–which makes the air expand so quickly that the shell is virtually certain to crack.
As the egg heats, a little bit of the protein in its white will decompose, releasing sulfur that links up with hydrogen in the egg, forming hydrogen sulfide, the gas that gives rotten eggs their distinctive smell. The hydrogen sulfide collects near the coolest part of the egg–the yolk. The yolk contains iron, which now displaces the hydrogen in the hydrogen sulfide to form a green iron-sulfide ring around the hard-cooked yolk.