Question

Examine the following Java-like code:      ```java     class Parent {         String name = "Parent";         public void display() {             System.out.println(name);         }     }     class Child extends Parent {         String name = "Child";         // No display method override     }     public class Main {         public static void main(String[] args) {             Parent p = new Child();             p.display();         }     }     ```     What will be the output?

A Parent
B Child
C Compilation Error
D Runtime Error
Practice Next

Hey! Ask a query