Vidyalelo
Java Programming · Q41

Inheritence

Programming · Java Programming · question 41

Q41

What will be the output? class One final int a = 15; class Two extends One final int a = 20; public class Test extends Two final int a = 30; public static void main(String args[]) Test t = new One(); System.out.print(t.a);

A.
15
B.
20
C.
30
D.
Compiler Error
Answer
E.
None of these

Answer: Option D

Solution

Answer: Option D
Solution:

We can't store super class object in subclass reference But we can store subclass object in super class reference.