For Windows, you can run both on the same machine if they are installed with different directories. The default directories are fine. It is also possible to run multiple versions on Linux and Mac but much more difficult to set up, I won't try to explain it here.
The database format for the two versions is slightly different, you can open the 4.2.x on version 5 but not vice versa. If you do open the 4.2.x version on 5, it will ask you to upgrade the database. Attempting to open the upgraded database on version 4.2.x will not work.
If you want to share data between the two versions, it is recommended that you backup or export to XML, and then import into the other version.