Question

What will be the output of the following Java snippet? class A {     public void display() {         System.out.println("Class A");     }} class B extends A {     public void display() {         System.out.println("Class B");     }} public class Test {     public static void main(String[] args) {         A obj = new B();         obj.display();     }}

A Class A
B Class B
C Compilation Error
D Runtime Error
E None of the above
Practice Next

Hey! Ask a query