Question

What is the output of the following code?     class Parent {         void show() { System.out.println("Parent"); }     }     class Child extends Parent {         void show() { System.out.println("Child"); }     }     public class Test {         public static void main(String[] args) {             Parent p = new Child();             p.show();         }     }

A Child
B Parent
C Compilation error
D Runtime exception
E Nothing is printed
Practice Next

Hey! Ask a query