The answer is: A
Explanation
The correct option is A. Z has not committed any offence as per section 98 of IPC and X has the same right of private defence which he would have if Z were sane.
According to section 98 of IPC, when an act, which would otherwise be a certain offence, is not that offence, by reason of the unsoundness of mind of the person doing that act, every person has the same right of private defence against that act which he would have if the act were that offence.
Illustration (a) of section 98 of IPC is exactly the same as the given scenario: Z, under the influence of madness, attempts to kill A; Z is guilty of no offence. But A has the same right of private defence which he would have if Z were sane.
The right of private defence is a right inherent in a person to protect one's own body and property or another's body and property from harm, when immediate aid from the state machinery is not available. The right of private defence is not an offence, but a defence to justify an act that would otherwise be an offence.
Therefore, option A is correct and the rest are incorrect. Option B is incorrect because X has not committed any offence by defending himself from Z's attack. Option C is incorrect because Z's act is not an offence by reason of his unsoundness of mind. Option D is incorrect because option A is correct.