How to handle PopUps and Alerts in Selenium with examples?

How to handle PopUps and Alerts in Selenium with examples?