posted 11 years ago
Hi Rachel,
You need to understand few concepts. first of all constructors are not inherited. the members of class instance or static members are inherited. Constructors are for Object Initialization so there is no inheritance.
Secondly when you make an object of a class with new operator for e.g say i have a class structure like this
class B
{
}
class A extends B
{
}
now if i do new A(); what will happen ? it will call constructor of A(in this case since i have not typed a constructor it will call compiler supplied default no-arg constructor). now the first call in this constructor will be of super() which will call B's default constructor which again have a super class which will ultimately call Object class constructor. Now SubAlpha has a private constructor , which means you cannot create object of this class from OUTSIDE of this class. if you do you will get compile time error. the question creates object of SubSubAlpha like new SubSubAlpha(); now SubSubAlpha extends Alpha and NOT SubAlpha. had SubSubAlpha extends SubAlpha then you would get a compile time error.
in short the answers to your question is that SubAlpha constructor is not called because we are not calling it i.e the program is not calling it. and the protected constructor of Alpha is called because SubSubAlpha extends Alpha and we are creating object of SubSubAlpha which calls constructor of Alpha.
also keep in mind constructor of Alpha has a protected access, so it will be called from only from the classes which extends Alpha.