vvus bharadwaj wrote:I know that variables are inherited in child class from base class.But how the variables behave when we declare same variables in child class as in base class.Are the variables in base class are overwritten or hidden?
Variables are not overwritten. there is nothing overwritten , whether in case of methods(which can be overridden) or variables. when you declare variable with the same name as in superclass in your subclass , the variables are just hidden. they are not inherited, not overwritten. they are just not there in subclass/childclass. however you can use super reference to access the hidden variables.