Solution 1:

Not quite. The file is already open by the program. Deleting the file ( and then replacing it with another version ) does not affect the running program because the original file is held open ( though without a name on disk to open it again ) until the program is done with it. Only when all handles to the file are closed are its data blocks on disk released. Until then the open file can be read and written just like normal -- the only change is that nobody else can open it since its name has been removed.

While parts of the program may have already been read into ram when it is deleted, they may still be discarded and re-read later, or new parts of the program that had not previously been executed can still be loaded from the deleted file.

Solution 2:

Is the xterm process cached in RAM whilst it is running?

Exactly. It's similar to the process that allows you to install updates to things while they're running without them crashing. And also why you have to restart services after you update them. Once something is running, its binary is in memory.

If it depends on other files (that aren't in a held "open" state) that are removed or replaced, that might cause issues but for something as discrete as xterm, that isn't an issue.