I know that in simple words an Object is created. But i will better make it clear it with a scenario,
class A {
public A(String path){
}
}
class AB extends A{
public AB(String path){
super(path);
}
}
class B{
public void foo(){
AB a = new AB("myPath");
// now will constructor of class AB will run on another instance of
// AB or is there any other way "a" constructed.
}
}
I’m asking this because if constructor runs on another instance (in this case AB), then who will give it the String path required (and after all no default constructor is allowed here.)
There is no “another instance” in this code; there’s just the one.
new AB("myPath")callspublic AB(String path)which in turn callspublic A(String path), all on the same instance.An instance of
ABis-an instance ofA, which in turn is-an instance ofObject.