Question: How Would An EC2 Instance Find Its Private And Public IP Addresses?

How would an Amazon EC2 instance find its private and public IP addresses?

.

How do I find the public IP address of my EC2 instance?

How is the public IP address managed in an instance session?

What happens when EC2 stops its public and private IP?