What will be the output of this code?
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
This question is part of this quiz :
Java Polymorphism and Packages