I am trying to understand the output of the java toy program below...
public class BaseWithPrint {
public BaseWithPrint(){
print();
}
public void print(){
System.out.println("BaseWithPrint.print");
}
}
class DerivedWithPrint extends BaseWithPrint{
int i = 47;
public void print(){
System.out.println("i = " + i);
}
}
class Initialization_MYCLASS{
public static void main(String args[]){
DerivedWithPrint dp = new DerivedWithPrint();
dp.print();
}
}
The output of this file is:
i = 0
i = 47
I understand why I get the second line. But is the first line i = 0
?