How you connect 40Ah and 28Ah batteries of same voltage?
It depends on the voltage you wish to use - if the voltage is,
say 12 volts (and matches exactly), you could place in parallelel
for 12 volt output, and the ability to serve more current. If you
want 24 volts, put them in series.
If you do place them in parallel, note the 28Ah battery will
discharge sooner than the 40Ah, causing the 28Ah battery terminal
voltage to drop, which will cause the 40Ah battery to attempt to
charge the 28Ah battery up to the full voltage again.