What will be the output of this code?

Last Updated :
Discuss
Comments

What will be the output of this code?

Java
class Parent {
    static void show() {
        System.out.println("Parent");
    }
}
class Child extends Parent {
    static void show() {
        System.out.println("Child");
    }
}
public class Main {
    public static void main(String[] args) {
        Parent p = new Child();
        p.show();
    }
}


Parent

Child

Compilation error


Runtime error

Share your thoughts in the comments