If the generator is rated 40 KW, it doesn't mean the generator pours out 40 KW
whenever it's running. It means you can take as much power as you want from it
as long as you don't try and take more than 40 KW for too long, because that could
overheat or damage the generator.
Notice that your 40 KW is just the product of the rated voltage and current:
120 V times 333 A = 39,960 watts = nominal "40 KW".
We point that out in order to mention that the voltage and current rating of the
generator are irrelevant to the answer.
If you load the generator to its max of 40 KW continuously for 24 hours, then
it delivers (40 x 24) = 960 KWH of energy.