Yes, you can run MySQL 4 and 5 on the same machine, but you must install them in different directories (obviously), use different tcp port numbers, and different unix socket / NT pipe names.
You will probably want to use the mysql5 client libraries if possible, although these are entirely backwards compatible and will talk to the v4 server as well
Mark