Tech Mahindra interview question

Write program for singleton pattern and explain?