class B{
int x;
B(){ x = 10;}
void m1(){x = 20;}
void m1(int x){this.x = x;}
}
class A extends B{
int x;
A(){x = 20;}
void m1(int x){super.x = x;}
public static void main(
String arf[]){
B x = new A();
System.out.println(x.x);
x.m1();
System.out.println(x.x);
x.m1(30);
System.out.println(x.x);
((A)x).m1(30);
System.out.println(x.x);
}
}
a. 10 20 20 20
b. 10 20 30 30
c. 20 20 20 30
d. 20 20 20 20
e. Compiler error or run time error.
f. None of the above, it will give another output.
Answer is given as b, can anyone explain pls.
-Arun