We have below code:
class Parent {
public int i = 5;
}
class Son extends Parent {
}
public class MyTest {
public static void main(String[] args){
**Son son = new Son();**
System.out.println(son.i);
}
}
When execute Son son = new Son(), below questions confused with me:
- Will create Parent instance in memory or not? I know that before create Son instance, will invoke Parent default Constructor with no parameter, is that correct invoking Constructor and create instance are different things?
- If did not create Parent instance, but where is field i store in Son instance? Cause we can get value of i via son reference?
Many thanks!!!