It's impossible to diagnose without more information. It could be almost anything... If it's a hardware fault it could be a bad processor, a dying logic board, a bad stick of RAM, or a dying power supply, just to name a few things.
Some of the G5 iMacs are notorious for logic board failure due to Apple's decision to use very low quality capacitors on the board (interestingly enough, many PC motheboard manufacturers had encountered this problem-and corrected it-LONG before Apple released the G5 iMacs. It was a major issue, one that was very widespread and well-known. Apple should've known better). These capacitors have a defective electrolyte formula that causes the buildup of gases in the capacitor. This causes the capacitor to bulge and leak, which in turn causes them to drop out of spec or fail to operate completely. This then leads to all kinds of weird problems, and eventually to complete logic board failure.
Pictures, if you're curious, of what these capacitors look like (courtesy of my own dead iMac G5 logic board):
AAAAAAAAANYHOW...., back to your problem. Have you reset the SMU and the PRAM? If not, you should start with those.
Resetting the SMU
Resetting the PRAM
If you try those, and it still has this problem, we'll need some more information... Like when did it start? Was it just after you installed a piece of software, or just after you moved the machine around or anything? Has the board in this machine ever been replaced due to bad capacitors? Does it make any strange noises? etc.