Hard Drive Replacement


I recently installed 512 MB RAM, a new battery and a 20GB HDD in an iMac. I upgraded the RAM first. It checked out ok. Then I replaced the battery and the HDD. When I started up I got the ? on the screen. I take it that the new HDD was not recognized. Unfortunately I also attempted to start up with a restore CD. I have no idea whether this has anything to my issue, but now the cd will not eject (slot drive).
'When I started up I got the ? on the screen.', - well, yes - since the '?' signifies that no OS was detected.

'I take it that the new HDD was not recognized.', - maybe / maybe not. You 'took it' incorrectly, as per the above statement - the hdd may have been detected, just no OS.

'... I also attempted to start up with a restore CD ... but now the cd will not eject (slot drive).'. The CD player is wired as a 'master'; when you installed the hard disk drive - did you jumper it as a 'slave'?

Anyway, to eject the CD ... restart (reboot), or turn OFF and then ON, the Mac - with the mouse button pressed and kept pressed during the boot up process.
If that attempt fails, locate the eject button and try to manually eject the disc.
Barhar is correct in getting that CD ejected. Just restart the computer and hold down the mouse button. The CD should eject.

The hard drive should be set to master not slave.
The Restore CD works when you have an OS on the drive already.

You need a retail/full install version of an OS CD and then use Drive Setup first to format the drive using Mac OS Extended.

Start up the computer, insert the OS CD, immediately hold down the C key. The Computer should start up with the CD.
Go to the Utilities folder on the CD and select Drive Setup. Use that to format the drive. When done, use Disk First Aid to check over the drive.

Now click twice on the installer icon on the CD and follow the prompts.
I removed the 20 GB HDD and installed the original HDD and ejected the stuck disk after it started on the original HDD. I then installed the 20 GB HDD again and used another disk to start. Right away it recognized the HDD and went through the the proceedure for loading the OS, except I think I also loaded a phantom OS ( ? ) which it goes to first ,then goes to the real OS (happy Mac) and then proceeds to start up. The phantom is just momentary (5 sec ), and does not affect system performance that I can detect. I decided to ignore the phantom. The computer, which is going to a friend as a freebie said ,"send the computer", so now it's gone, and I know a little more about Macs . I have 13 more to learn on, 3 iMacs and 10 Beige PowerMac G3s to be exact. All will get larger HDDs , more memory and batteries. Thanks for the help.
That Phantom OS start up is probably the computer looking for the System folder.

The next one you do, after the install and restart, go to the Apple Menu>Control Panels>Startup Disk. Select the drive with the OS on it, then close the window.

Now the 'phantom' will disappear.