You can install more than one version, but you shouldn't run those two at the same time (You can run two versions of Xcode 9 at one time, however). Also note if you open the same project with both, certain changes might occur that cause conflicts.
They will both work off the same preferences, so be careful if you elect to auto open certain projects when running Xcode to avoid unwanted changes. Be sure to have tested and reliable backups of all projects.
You might have trouble installing one or the other, so be prepared to rename one, such as 'Xcode7', then use Xcode 9 simply as 'Xcode' - don't be surprised if installing one, wipes out the other.