It depends on the G4 model. The later models of the G4 (Dual 1.25Ghz (mirrior Doors) have DDR SDRAM DIMMs which are PC 2700 and the G5's are compadable with that PC and DIMM.
I would check at a RAM seller's web site. See if the same thing comes up for your computer and the G5 you want. Personally I think it is unlikely that they would be compatable unless you have a very late model G4 and want the 1.6 G5. Crucial OWC