Computer Applications
Java resolves duplicate variable name to ……………. .
- global variable
- local variable
- most local scope variable
- all the above
Answer
most local scope variable
Reason — Java resolves duplicate variable name to most local scope variable. For example, if a local variable is having the same name as that of a global class element, then the most local variable with the same name will be considered. The global variable will be hidden by the local variable.
Related Questions
Through which access specifier, a class makes its element visible to all ?
- public
- private
- protected
- friendly
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
A member method that returns the value of a private data member is called …………… .
- setter
- getter
- manager
- accessor
A member method that can change the value of a private data member is called …………… .
- setter
- getter
- manager
- accessor