static overrridden | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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?

27th Jul 2019, 8:54 PM
ABADA S
ABADA S - avatar
3 Answers
+ 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?
27th Jul 2019, 9:09 PM
ABADA S
ABADA S - avatar
+ 3
great thanks for explanation
27th Jul 2019, 9:11 PM
ABADA S
ABADA S - avatar
+ 1
they call it "Hidden/Hiding" instead overridden here
28th Jul 2019, 5:59 AM
zemiak