This is the source of much of our collective imagination about robots.
And all the dystopian movie plots about robots overthrowing humans and killing them all. I think that is completely projection - somebody is thinking "well, if I were a robot, I'd kill everybody." It really says a hell of a lot more about humans than robots.
For robots to take over the world or kill all humans, first they'd have to give a shit. They'd have to perceive themselves as oppressed or something. And have some motivations, akin to emotions, driving the behavior. Good luck on coding that up.