[HD Pg 0, Sec. 12.1.4 - inheritance-of-instance-methods-vs-static-methods]
Posted: Tue Oct 22, 2019 7:01 pm
Statement copied from page 265: "Conceptually, however, the difference that I highlighted above for variables also exists for methods. Conceptually, a subclass inherits its own copy of an instance method. This is proven by the fact that a subclass can completely replace the behavior of an inherited instance method for objects of the subclass by "overriding" it with a new implementation of its own without affecting the behavior of the superclass's implementation for objects of the superclass. On the other hand, a subclass merely gets access rights to a static method of its superclass and so, the subclass cannot change the behavior of the inherited static method. The subclass can "hide" the behavior of the superclass's static method by providing a new implementation but it cannot replace the super class's method ".
Deshmukh, Hanumant. OCP Oracle Certified Professional Java SE 11 Programmer I Exam Fundamentals 1Z0-815: Study guide for passing the OCP Java 11 Developer Certification Part 1 Exam 1Z0-815 (p. 265). Enthuware. Edição do Kindle.
Kindly, can you explain by some example what is the difference between "overriding" and "hide"? Well, it is clear that regard overriding "a subclass can completely replace the behavior of an inherited instance method for objects of the subclass by "overriding" it with a new implementation of its own" and about hiding it can be reached by "providing a new implementation". Well, at the end, isn't exactly the same result? I read carefully https://stackoverflow.com/questions/105 ... a-confused and as far as I can see it is just a semantic approach: weather is not static then it is override while weather this is static then we call hide. At the end we replace behaviours in either case.
Deshmukh, Hanumant. OCP Oracle Certified Professional Java SE 11 Programmer I Exam Fundamentals 1Z0-815: Study guide for passing the OCP Java 11 Developer Certification Part 1 Exam 1Z0-815 (p. 265). Enthuware. Edição do Kindle.
Kindly, can you explain by some example what is the difference between "overriding" and "hide"? Well, it is clear that regard overriding "a subclass can completely replace the behavior of an inherited instance method for objects of the subclass by "overriding" it with a new implementation of its own" and about hiding it can be reached by "providing a new implementation". Well, at the end, isn't exactly the same result? I read carefully https://stackoverflow.com/questions/105 ... a-confused and as far as I can see it is just a semantic approach: weather is not static then it is override while weather this is static then we call hide. At the end we replace behaviours in either case.