What would happen if an A340 pilot was on a B777 or a B747 flight as a passenger and for some reason the 777 pilots couldn't continue the flight? Can the 340 pilot fly a 777 and land it?
Is an A330 pilot able to fly an A340?
The A330 and A340 cockpits are nearly identical, so definately yes, a pilot would be able to fly either one.
A Boeing pilots and Airbus pilot would be able to fly each other's aircraft if they had to. Basic technique of flying an aircraft is the same, even if the cockpits are quite different. It would not be easy, but it would by no means be impossible.