The general explanation is provided in the link from Dan.
For specific questions your ask :
They can reside on the same machine, even in the same process (JVM for Java). It is a logical distinction (what they do?), not a physical one (where they are?).