During my masters, I used to ask a lot of questions in class and during the lecture. Whenever I had a doubt I used to ask questions. It was my habit which my undergraduate teachers inculcated in me and inspired us to do so. However, here, in my masters, I got the impression that this is probably a bad habit as professors tend to think that I am asking my questions to test them. Ultimately, it was proven to reflect badly on me.
I am about to go to another institution going for my PHD. Since then, I have changed my habit and I haven't asked a single question in the last several lectures. Instead, I wrote my questions down in my notebook and later read books or Googled them to search for answers.
Is this really the right way?
How can I ask a question such that the professors shall not think that I am somehow mocking them?