I know you are shy when the lecturer asks you a question in front of students and the lecturer himself or herself. You are afraid of what other students will say or what the lecturer will say, but let them say anything. Don't be afraid too much as if they will murder you or eat you. Your fear causes nervousness and nothing else. You are shy because they fear keeps on haunting your mind what lecturers will say. Your fear seems to block you from facing challenges.
So just remove your fear from your mind. Let me one question which may motivate you. In life, what is the end? Definitely death. So do you fear that? Definitely yes? So if anyone insults you or beat you or scold you or harass you or even torture you or embarrass you face many problems in life, does it mean that your life has ended? Not, but mind it in which class you are in or whether you have passed 9th or 10th standard or will go to 9th or 10th standard, in 9th or 10th standard, there is one law in Physics or physical science called Newton's 3rd law of motion which states 'to every action there is always equal and opposite reaction'. So whether you are scolded or getting beaten or getting threatened or insulted or harassed, you react. So does your reaction lasts throughout your life? Never. Your reaction is short-lived and then everything will become normal. So there is no point in getting afraid. If you face action due to your mistakes and even if you face reaction due to this, then try to rectify those mistakes and never do the same mistake again and again, so that you may face action because of your mistakes. Always believe in God and for all your mistakes, God will forgive you and give chance to rectify those mistakes, unless you have done terrible mistakes in the worst case which involves harming others or murdering others or violation of rules by the government or crime which will result facing legal consequences by the government say police and I ask you one question have you done or involved in such terrible mistakes for which you will face legal consequences. In that case, God may not easily forgive you. I hope as per your question you are young and innocent and most probably or 99 percent chance that you haven't involved in any such mistakes. Even you are too immature to do such mistakes but mind it never do such mistakes in your life for which you may have the chance to face legal action by the government. If you haven't done any mistakes for which you don't have any possibility of facing legal action by the government but you faced some action like getting beaten, getting scolded, getting insulted, getting backbitten, or even lost your job if you are adult or getting a disease, in that case, you will get short term reaction and God will forgive you and allow you to rectify your mistake only if you realize your mistakes. So there is no point in getting afraid if your mistakes are rectified after you realize your mistakes and if you don't do the same mistake again and again.
So, after explaining so much, I hoped your fear has been reduced somewhat but there is one catch, why? I have explained ways of reducing your fear when you have done a mistake, but what will happen if you are innocent and you are misjudged, or you are in fear of something which you are not sure even if you have not done any mistake. In this case, you either try to avoid doing something for which you know you are feared when you feel that anything can happen to you if you do this, or stop overthinking too much when you are not sure what will happen if you do this. For example, now it is the time of coronavirus pandemic and you have a fear in your mind that if you go out of the home, you have the chances that coronavirus will infect you. Do you know in what cases, you have a fear that you will get infected? If you go outside unnecessarily without wearing protective masks or you are close to outside people, then you have the chances of getting coronavirus and better avoid going out of the home unless necessary and if you have to go out of the home then always wear masks, gloves or even face shield and avoid staying close to outside people, then you have hardly any risk of getting infected. So don't get afraid of getting infected. If you follow the rules and wear protective items and still you have the fear of getting infected and the reason for which you don't know then stop overthinking unnecessarily that anything will happen to you and be cool and there will be no fear within you.
So I have explained ways to reduce your fear completely and for your question, my answer is to remove your fear and your shyness will be gone. Coming to your question, by applying the way which I have explained to reduce fear, I can tell that you have a fear in your mind because of your excessive overthinking that means you think too much what will students say whether your answer which you claim correctly is wrong by the teacher and what action will teacher give when your answer is claimed to wring by the teacher. The only way I can suggest you is to stop overthinking. If your lecturer or teacher satisfies with your answer, then there is no point of getting afraid. If your answer is not claimed correctly by the teacher and if you face action because of this, then as I have explained, face action, get a reaction, realize your mistake, rectify your mistake. In this case, God will give you a chance to rectify mistakes again. If you don't do the same mistake again, they will never face action because of your mistakes. Mind it, no one is perfect and every make mistake, some learn from a mistake and some don't learn from the mistake. So in this case whatever mistake you make other than terrible mistakes which I have mentioned above, then God will allow you to rectify your mistake after you realize it. So no fear.
My final suggestion, remove fear, nervousness will stop, shyness will stop, confidence will come.