Step 1: Understanding the Line of Succession
The question asks who acts as President when the offices of both the President and the Vice President are vacant (due to death, resignation, removal, or otherwise).
Step 2: Legal and Constitutional Provisions
Article 65 of the Constitution states that the Vice President shall act as President in the event of a vacancy in the office of the President.
The Constitution was initially silent on what would happen if the Vice President's office was also vacant.
To address this, Parliament enacted the President (Discharge of Functions) Act, 1969.
This Act provides that if the offices of both the President and Vice President are vacant, the Chief Justice of India shall act as the President.
The Act further provides that if the Chief Justice is also unavailable, the senior-most Judge of the Supreme Court available shall perform the functions of the President.
Step 3: Historical Precedent
This situation has occurred once in India's history. In 1969, following the death of President Zakir Hussain and the resignation of Vice President V.V. Giri (to contest the presidential election), the then Chief Justice of India, Justice Mohammad Hidayatullah, served as the acting President of India for a brief period.
Step 4: Final Answer
In the absence of both the President and the Vice President, the Chief Justice of India (or the senior-most Supreme Court Judge if the CJI is also unavailable) performs the duties of the President. Therefore, option (D) is the correct answer.