iMac G5s can be very unreliable. The iMac G5s were manufactured during the height of CAPACITOR PLAGUE, where electrolytic capacitors became very unreliable and prone to failure due to faulty manufacturing formulas and other problems. Out of all Apple computers manufactured during this time, iMac G5s were hit to worst by this problem. The early iMac G5 models A1058 and A1076 are the worst of all of them, with the later Ambient Light Sensor models being significantly more reliable.
If you have an iMac G5, working or dead, if you want to check the capacitors, all you have to do is take off the back cover and do a visual inspection. If you see any capacitors that appear to be "bulging" from the top, or if any of them appear to be leaking rusty brown gunk from the top, you have some bad caps. Replacing them is possible, but very difficult. I would recomment avoiding the A1058 and A1076 models if you want one that won't be as likely to fail.
Other issues that are common across all computers from this time include failing hard drives, dead PRAM batteries, and dust/dirt causing issues.
If you have one of these G5 iMacs, I would strongly recomment taking off the back cover, cleaning out the fans, and replacing the thermal paste on the CPU die for improved thermal performance and a longer life.
Unlike earlier models, the iMac G5 uses CR2032 coin cell batteries instead of Half-AA Lithium batteries. Because of this, you really don't have to worry much about them leaking. Still, considering how common and cheap they are, why wouldn't you just replace it anyway to get working clock again, as many are starting to die.