Can 2.40 tires fit a 20 inch rim? Can 2.40 tires fit a 20 inch rim/wheel. I want move up from 2.35 tires but I'm not sure if I  have to buy bigger rims/wheels or if I can ride it with the 20 inch wheels.
Your question can't be answered as written.

The rim diameter (20") is not directly correlated with the tyre width.

Since your frame can fit a 2.35" wide tyre, there's a very good chance a 2.4" tyre will fit.  However it is an increase of 2.1% so if you're running close now you may be out of luck.

The only time the rim dictates tyre width is the inner width of the valley of the rim.



So your 2.35" tyre is 59mm moving to 2.4" which is 61mm.  Chart suggests your rim will be fine.

TL;DR your frame is the limiting factor, not the rim.