What is variable hiding and variable shadowing and what are the difference between variable hiding and shadowing?
Variable hiding —> Whenever the global variable and local variable is same then it is called as variable hiding. To overcome this issue we use this keyword to access the current variable.
Variable shadowing —> When the subclass variable is same as parent class variable then the subclass variable hides the parent class variable is call as Variable shadowing. To overcome this issue we use this and super keyword .
To access the current class variable we can use this() keyword in java AND to access super class variable we can use super() keyword.
Difference between the variable hiding and variable shadowing
Variable hiding is possible in same class only. In this local variable hides the global variable.
Variable shadowing is not possible without inheritance. In this concept subclass variable hides the super class variable.