In this case, the final key indeed is calculated offline.If you want to implement this algorithm, look at the example in the article.The figure clearly shows it combines both keys to generate a shared secret.

validating diffie hellman public private keys-16validating diffie hellman public private keys-63

They are just used to communicate the secret between the two parties. In the article, it says the shared secret is computed offline by both parties.

By offline, I assume it means no further exchange between the two parties are needed?

It could easily be a hacker spoofing peer A’s identity.

This led to the more advanced public key cryptography in RSA.

The idea in Diffie-Hellman is to encrypt a symmetric key with the public key of the communication partner so it can be transmitted safely.

The communication partner can decrypt the symmetric key with her private key.

The Diffie-Hellman algorithm was created to address the issue of secure encrypted keys from being attacked over the internet when in transmission, though using the Diffie-Hellman algorithm in distributing symmetric keys securely over the internet.

The process works by two peers generating a private and a public key.

You can use it with public an private keys, but I can't really see the point because when you're working with public and private keys, it's not necessary to calculate a shared secret.