EveryMac says that the Max supported RAM is 16GB. Over this, the machine probably will accept and use the RAM but will not use all of it. If it is the same as my old MacBook from 2006, I installed 4GB of RAM (the max) but only used 3.3GB due to hardware limitations.
It depends on which model iMac you have.
Core 2 Duo models can use up to 16 GB RAM only, while the i5 and i7 models can, unofficially, use up to 32 GB of RAM.