When you run the above code, it will generate and print two 2048-bit public keys (for Alice and for Bob). Assume that Allice and Bob have exchanged their public keys (e.g. send them to each other through Internet). Once Alice has received Bob's public key, she can calculate the shared secret by combining it to her private key. Respectively, once Bob has received Alice's public key, he can calculate the shared secret by combining it to his private key. The sample output from the above example shows that the shared secret is always the same number (2048-bit integer):

Note that your output will be different due to the randomness during the key generation process. The above code uses a 2048-bit public and private keys, as specified in the RFC 3526 (group 14). You can change the DHKE key size (from 1536-bits to 8192-bits) by specifying a different RFC 3526 group (e.g. 18 for 8192-bit keys). For example change these two lines: