There are 3 ways an answer can be deleted:
- The post owner manually deletes it.
- A diamond moderator manually deletes it.
- The answer is deleted as part of a question deletion, which can be done by the question owner (subject to a set of criteria that determines overall question value), diamond moderators, and 3 (or more, subject to question value criteria) 10k users after the question has been closed for 2 days.
There are also 3 ways an answer can be undeleted:
- The post owner manually undeletes it.
- A diamond moderator manually undeletes it.
- The answer is undeleted as part of a question undeletion, which can be done by the question owner (under certain conditions? I'm not sure), diamond moderators, and 3 or more 10k users (subject to the criteria above) with no time limit since the question was deleted.
This all assumes that the answer isn't locked, in which case only a diamond moderator can delete or undelete (I believe they must release the lock first, though).
There are no time limits on when you can delete or undelete your own posts, and delete/undelete votes do not expire like close votes do. AFAIK, deleted content sticks around forever, unless there's been a policy change I'm not aware of. (Or, one of the devs has been mucking in the database, but that's exceedingly rare.)