+ 1
What is the difference between shadowing and overriding in java??
both looks similar to me. Can anyone make me clear.
2 Answers
+ 1
Instance methods can be overridden, static methods can not be overridden only hidden. They are similar, but the instance based doesn't care which class (parent or child) the instance is stored as only how it was created. To reference the child static, you must explictly specify the child class.
+ 1
that means if a method is static, then we cant override it in the sub class.
if we create a object of the subclass and invoke the static method. then, it will give call method from the parent class as the method in sub class is just a shadow of method in parent class.