If there is a private constructor, does the JVM add a call to the super constructor?
I mean the call super()in this private constructor.
class Alpha {
static String s="";
protected Alpha(){
s+="alpha";
}
}
class SubAlpha extends Alpha{
private SubAlpha(){
s+="sub";
}
}
class SubSubAlpha extends Alpha{
private SubSubAlpha(){
s+="subsubAlpha";
}
public static void main(String[] args){
new SubSubAlpha();
System.out.print(s);
}
}
Here I am not getting any compilation error. Here in the class SubSubAlphathere is a private constructor. This compiler call inserts super(), if so, what happens in the class SubAlpha. There is even a private constructor. And if it's not available, how does the inheritance tree continue to the top.
source
share