Q. 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) None of These
πŸ’¬ Discuss
βœ… Correct Answer: (B) Child

You must be Logged in to update hint/solution

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
98
Total Visits
πŸ“½οΈ
1 y ago
Published
πŸŽ–οΈ
Ritu Nagar
Publisher
πŸ“ˆ
94%
Success Rate