NIELIT O Level Exam

What happens if a local variable exists with the same name as the global variable you want to access?

What happens if a local variable exists with the same name as the global variable you want to access?

यदि कोई लोकल वैरिएबल वैसा ही नाम के साथ मौजूद है जैसा कि ग्लोबल वैरिएबल जिसे आप एक्सेस करना चाहते हैं?

A. Error एरर

B. The local variable is shadowed लोकल वैरिएबल छाया हुआ है

C. Undefined behavior अनडिफाइन बिहेवियर

D. The global variable is shadowed ग्लोबल वैरिएबल छाया हुआ है




Correct Answer is :

D. The global variable is shadowed



Explanation
If a local variable exists with the same name as the local variable that you want to access, then the global variable is shadowed. That is, preference is given to the local variable.
Latest Current Affairs 2024 Online Exam Quiz for One day Exam Online Typing Test CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online MBA 2 years Online MCA Online BCA Best Website and Software Company in Allahabad