Why is the value of id = 0 when super class constructor is called within the derived class constructor? When child object is created, when is memory allotted in the heap for the object? After the base class constructor runs or before?
class Parent{
int id = 10;
Parent(){
meth();
}
void meth(){
System.out.println("Parent :"+ id);
}
}
class Child extends Parent{
int id = 5;
Child(){
meth();
}
void meth(){
System.out.println("Child :"+ id);
}
}
public class OverRidingEg {
public static void main(String[] args) {
// TODO Auto-generated method stub
Child a= new Child();
}
}