Can I override and overload static methods in Java? -
i'd know:
- why can't static methods overridden in java?
- can static methods overloaded in java?
static methods can not overridden in exact sense of word, can hide parent static methods
in practice means que compiler decide method execute @ compile time, , not in runtime, overridden instance methods.
for neat example have here.
and this java documentation explaining difference between overriding instance methods , hiding class (static) methods.
overriding: overriding in java means particular method called based on run time type of object , not on compile time type of (which case overriden static methods)
hiding: parent class methods static not part of child class (although accessible), there no question of overriding it. if add static method in subclass, identical 1 in parent class, subclass static method unique , distinct static method in parent class.
Comments
Post a Comment