If the airline you are traveling has issued a ticket with 40 minutes connecting time, yes indeed that's sufficient. Different airports have different minimum connecting times or M C T. It's decided by looking at the infrastructure, distance between terminals and other things.