In this question the output gives as Rose0. But when I go through the logic I feel the answer must be Rose100 instead of Rose0. How does compiler differentiate the i s in both classes. Since Rosea extends _39 class it has the super class i as well. But in line 1 if I change super.i then Im getting Rose100. How this differs?
class _39 {
int i;
_39(){
i=100;
foo();
}
public void foo(){
System.out.println("Flower"+i);}
}
}
public class Rosea extends _39{
int i=200;
Rosea(){
i=300;
}
public void foo(){
System.out.println("Rose"+i);
} //line 1
public static void main(String[] args) {
new Rosea();
}
}