ICSE Class 10 Computer Applications
Question 16 of 17
Encapsulation — Question 3
Back to all questions 3
Question Question 3
If a local variable is having the same name as that of a global class element, then it
- hides the global variable
- gets hidden by global variable
- produces an error
- none of the above
hides the global variable
Reason — If a local variable is having the same name as that of a global class element, the system resolves the name to the most local scope available i.e., most local variable with the same name will be considered. The global variable will be hidden by the local variable.