Let us consider one instance of arrangement of question.
So in this out of 40 , 17 is going to be true and remaining false.
So it is a problem of selection(combination) since the arrangement among the questions having "true" as answer will be counted 1 only and similarly for false.
So we have to select 17 out of 40 questions , the remaining are going to have "false" as the answer.
So no of ways to do this = 40C17 which is hence the number of keys possible for one arrangement of questions.
Now this is for one arrangement of question sequence.
But given in the question we can have questions positioned in any order , so that needs to be taken into account.So ordering of questions matters .Also the questions will be distinct obviously.
Hence no of such question arrangements of 40 questions = 40!
Hence total no of keys possible overall = 40! * 40C17