A330s and A340s are essentially the same plane. The A330 is designed for shorter routes, with a higher density of passengers.
The A340 is the long range version. Some of the passenger capacity is removed to make way for the additional "stuff" required for the 4 engines, vs the 2 engines on the A330, as well as additional fuel capacity. As well, long range planes don't pack the passengers in quite as tightly as they might on shorter routes.