In either of those types of memory can a virus reside. Physical memory, however, is fairly permanent. A piece of information, data, file, program, or virus placed here will still be around in the event that the computer is turned off. Within this complex environment, exists computer viruses. There is no exact and concrete definition for a computer virus, but over time some commonly accepted facts have been related to them.
All viruses are programs or pieces of programs that reside in some form of memory.
They all were created by a person with the explicit intent of being a virus. Therefore, viruses are not created by accident. They can, however, be contracted and passed along by accident. In fact it may be weeks until a person even is aware that their computer has a virus. All viruses try to spread themselves in some way.