What does it mean that "replace the process's memory space with a new program"? So who's memory space will be replaced by whom?
A process memory space is :
and when you call fork with a process, the entire address space of that process gets copied, and we allocate some part of the memory to it, and when we call exec after doing fork, it replaces that copy (the child) with a new program. (note that we usually call exec only with the child, we do this in our code using the fact that the child will return 0 to the fork value and the parent will return the process id of that child, so we use the if command and use exec if its the child)
so to answer your question, we basically replace the address space of the child that was created, with another program.