Examveda
Examveda

What is the result of the following code snippet?

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

A. Compilation error

B. Child

C. Runtime exception

D. Compilation error

Answer: Option B


This Question Belongs to Java Program >> Overriding And Overloading

Join The Discussion

Related Questions on Overriding and Overloading