Computer Applications
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
Encapsulation & Inheritance in Java
9 Likes
Answer
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.
Answered By
5 Likes
Related Questions
A class encapsulates …………… .
- data
- methods
- functionality
- all the above
Through which access specifier, a class makes its element visible to all ?
- public
- private
- protected
- friendly
Java resolves duplicate variable name to ……………. .
- global variable
- local variable
- most local scope variable
- all the above
A member method that returns the value of a private data member is called …………… .
- setter
- getter
- manager
- accessor