Examining a robot called the Cougar Cannon that the Oakton High School students were demonstrating, Mr Obama said: “As president, I believe that robotics can inspire young people to pursue science and engineering.

“And I also want to keep an eye on those robots in case they try anything.”

Mr Obama’s joke came during a talk in Washington about science and maths education. It was attended by the first American woman in space, Sally Ride, as well as the team from the Mythbusters programme on the Discovery Channel.

Mr Obama expressed his hope that the Mythbusters “had left the explosives at home”.

The Cougar Cannon is a robot designed to scoop up and throw moon rocks, although in the absence of lunar material it demonstrated its abilities using foam balls.

In the Terminator films, a defence computer called Skynet becomes sentient and creates armies of robots to take over the world. The Cougar Cannon is not thought to pose the same threat, although it is not known how far it can toss the foam balls.