Vidyalelo
Java Programming · Q20

Inheritence

Programming · Java Programming · question 20

Q20

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
Answer

Answer: Option D

Solution

Answer: Option D
No explanation is given for this question Let's Discuss on Board