Wait, I'm standing fixed - static methods are inherited. Like. However, they do not act as the actual inheritance of the TOE. For example, with these classes:
public class Parent { public static void printIt() { System.out.println("I'm Parent!"); } } public class Child extends Parent { public static void printIt() { System.out.println("I'm Child!"); } public static void main(String[] args) { Parent child1 = new Child(); Child child2 = new Child(); child1.printIt(); child2.printIt(); } }
If you call child1.printIt() , it will use Parent.printIt() because child1 has been added to the Parent class. If you call child2.printIt() , however, it will use Child.printIt() because it is passed to the child. So this is not really true inheritance, because redefinition does not stick if you drop the supertype. So this is not true polymorphism.
Kaleb brasee
source share