A

Admin • 830.13K Points
Coach

Q. 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) 30 D. Compiler Error
  • Correct Answer - Option(D)
  • Views: 14
  • Filed under category Java
  • Hashtags:

Explanation by: Admin
We can't store super class object in subclass reference But we can store subclass object in super class reference.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.