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) {
Parent obj = new Parent();
obj.display();
}
}

A. Runtime exception

B. Compilation error

C. Parent

D. Child

Answer: Option C


This Question Belongs to Java Program >> Overriding And Overloading

Join The Discussion

Related Questions on Overriding and Overloading