?
What will be the output?
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);
}
}
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);
}
}
Answer & Solution
Correct Answer:
Option
D
We can't store super class object in subclass reference But we can store subclass object in super class reference.
Join the Discussion
Login to post a comment or share your explanation.
Loginin this case we use super keyword.