+ 5
static overrridden
//What is the output of this code? class Parent { public static void show() { System.out.println("parent class"); } } class Child extends Parent { public static void show() { System.out.println("child class"); } } public class Program{ public static void main(String[] args) { Parent p = new Child(); p.show(); } } here is a Child class inherits from a Parent class and override a static method called show and it works🙃 why ? isn't it an override?
3 Réponses
+ 3
aaa it will not cause a compile error but it will not happen also ..so it depends on the type of pointer
but final methods will cause error if I try to override it correct?
+ 3
great thanks for explanation
+ 1
they call it "Hidden/Hiding" instead overridden here