KnowledgeBoat Logo
|

Computer Applications

If a local variable is having the same name as that of a global class element, then it

  1. hides the global variable
  2. gets hidden by global variable
  3. produces an error
  4. 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