πŸ“Š JAVA
Q. What is the result of the following code snippet?

class Parent {
int x = 10;
}
class Child extends Parent {
int x = 20;
void display() {
System.out.println(super.x + " " + x);
}
}
public class Main {
public static void main(String[] args) {
Child obj = new Child();
obj.display();
}
}
  • (A) Runtime exception
  • (B) Compilation error
  • (C) 20 10
  • (D) 10 20
πŸ’¬ Discuss
βœ… Correct Answer: (D) 10 20

You must be Logged in to update hint/solution

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
100
Total Visits
πŸ“½οΈ
1 y ago
Published
πŸŽ–οΈ
Ravi Shankar
Publisher
πŸ“ˆ
90%
Success Rate